< prev index next >

modules/javafx.controls/src/main/java/javafx/scene/control/skin/LabeledSkinBase.java

Print this page

        

*** 23,32 **** --- 23,33 ---- * questions. */ package javafx.scene.control.skin; + import javafx.geometry.Point2D; import com.sun.javafx.scene.control.LabeledText; import com.sun.javafx.scene.control.behavior.TextBinding; import com.sun.javafx.scene.control.skin.Utils; import javafx.application.Platform; import javafx.beans.InvalidationListener;
*** 571,587 **** // TODO Baseline may not be handled correctly // may have been CENTER, BASELINE, or null, treat as center contentY = (y + ((h - contentHeight) / 2.0)); } ! double preMnemonicWidth = 0.0; double mnemonicWidth = 0.0; double mnemonicHeight = 0.0; if (containsMnemonic) { final Font font = text.getFont(); String preSt = bindings.getText(); ! preMnemonicWidth = Utils.computeTextWidth(font, preSt.substring(0, bindings.getMnemonicIndex()), 0); mnemonicWidth = Utils.computeTextWidth(font, preSt.substring(bindings.getMnemonicIndex(), bindings.getMnemonicIndex() + 1), 0); mnemonicHeight = Utils.computeTextHeight(font, "_", 0, text.getBoundsType()); } --- 572,588 ---- // TODO Baseline may not be handled correctly // may have been CENTER, BASELINE, or null, treat as center contentY = (y + ((h - contentHeight) / 2.0)); } ! Point2D mnemonicPos = null; double mnemonicWidth = 0.0; double mnemonicHeight = 0.0; if (containsMnemonic) { final Font font = text.getFont(); String preSt = bindings.getText(); ! mnemonicPos = Utils.computeMnemonicPosition(font, preSt, bindings.getMnemonicIndex(), this.wrapWidth, labeled.getLineSpacing()); mnemonicWidth = Utils.computeTextWidth(font, preSt.substring(bindings.getMnemonicIndex(), bindings.getMnemonicIndex() + 1), 0); mnemonicHeight = Utils.computeTextHeight(font, "_", 0, text.getBoundsType()); }
*** 610,635 **** // Since I only have to position the text, it goes at the // contentX/contentY location. Note that positionNode will // adjust the text based on the text's minX/minY so no need to // worry about that here text.relocate(snapPositionX(contentX), snapPositionY(contentY)); ! if (containsMnemonic) { mnemonic_underscore.setEndX(mnemonicWidth-2.0); ! mnemonic_underscore.relocate(contentX+preMnemonicWidth, contentY+mnemonicHeight-1); } } else if (ignoreText) { // there isn't text to display, so we need to position it // such that it doesn't affect the content area (although when // there is a graphic, the text isn't even in the scene) text.relocate(snapPositionX(contentX), snapPositionY(contentY)); graphic.relocate(snapPositionX(contentX), snapPositionY(contentY)); ! if (containsMnemonic) { mnemonic_underscore.setEndX(mnemonicWidth); mnemonic_underscore.setStrokeWidth(mnemonicHeight/10.0); ! mnemonic_underscore.relocate(contentX+preMnemonicWidth, contentY+mnemonicHeight-1); ! } } else { // There is both text and a graphic, so I need to position them // relative to each other double graphicX = 0; --- 611,635 ---- // Since I only have to position the text, it goes at the // contentX/contentY location. Note that positionNode will // adjust the text based on the text's minX/minY so no need to // worry about that here text.relocate(snapPositionX(contentX), snapPositionY(contentY)); ! if (containsMnemonic && (mnemonicPos != null)) { mnemonic_underscore.setEndX(mnemonicWidth-2.0); ! mnemonic_underscore.relocate(contentX + mnemonicPos.getX(), contentY + mnemonicPos.getY()); } } else if (ignoreText) { // there isn't text to display, so we need to position it // such that it doesn't affect the content area (although when // there is a graphic, the text isn't even in the scene) text.relocate(snapPositionX(contentX), snapPositionY(contentY)); graphic.relocate(snapPositionX(contentX), snapPositionY(contentY)); ! if (containsMnemonic && (mnemonicPos != null)) { mnemonic_underscore.setEndX(mnemonicWidth); mnemonic_underscore.setStrokeWidth(mnemonicHeight/10.0); ! mnemonic_underscore.relocate(contentX + mnemonicPos.getX(), contentY + mnemonicPos.getY()); } } else { // There is both text and a graphic, so I need to position them // relative to each other double graphicX = 0;
*** 668,681 **** textX = contentX + ((contentWidth - textWidth) / 2.0); graphicY = contentY + ((contentHeight - graphicHeight) / 2.0); textY = contentY + ((contentHeight - textHeight) / 2.0); } text.relocate(snapPositionX(textX), snapPositionY(textY)); ! if (containsMnemonic) { mnemonic_underscore.setEndX(mnemonicWidth); mnemonic_underscore.setStrokeWidth(mnemonicHeight/10.0); ! mnemonic_underscore.relocate(snapPositionX(textX+preMnemonicWidth), snapPositionY(textY+mnemonicHeight-1)); } graphic.relocate(snapPositionX(graphicX), snapPositionY(graphicY)); } /** --- 668,681 ---- textX = contentX + ((contentWidth - textWidth) / 2.0); graphicY = contentY + ((contentHeight - graphicHeight) / 2.0); textY = contentY + ((contentHeight - textHeight) / 2.0); } text.relocate(snapPositionX(textX), snapPositionY(textY)); ! if (containsMnemonic && (mnemonicPos != null)) { mnemonic_underscore.setEndX(mnemonicWidth); mnemonic_underscore.setStrokeWidth(mnemonicHeight/10.0); ! mnemonic_underscore.relocate(textX + mnemonicPos.getX(), textY + mnemonicPos.getY()); } graphic.relocate(snapPositionX(graphicX), snapPositionY(graphicY)); } /**
< prev index next >