diff --git a/src/org/jetuml/gui/tips/TipDialog.java b/src/org/jetuml/gui/tips/TipDialog.java index 70395e26..dfca6315 100644 --- a/src/org/jetuml/gui/tips/TipDialog.java +++ b/src/org/jetuml/gui/tips/TipDialog.java @@ -39,20 +39,12 @@ import javafx.scene.control.ScrollPane; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.Border; import javafx.scene.layout.BorderPane; -import javafx.scene.layout.BorderStroke; -import javafx.scene.layout.BorderStrokeStyle; -import javafx.scene.layout.BorderWidths; -import javafx.scene.layout.CornerRadii; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; import javafx.scene.text.Font; -import javafx.scene.text.Text; -import javafx.scene.text.TextAlignment; import javafx.stage.Stage; /** @@ -225,7 +217,7 @@ private VBox getTipAsVBox(Tip pTip) List tipElements = pTip.getElements(); - Node titleNode = getTipTitleAsTextNode(pTip); + Node titleNode = getTipTitleAsLabel(pTip); tipVBox.getChildren().add(titleNode); for(TipElement tipElement : tipElements) @@ -242,7 +234,7 @@ private VBox getTipAsVBox(Tip pTip) * @return Formatted Node containing the tip's title * @pre pTip!= null */ - private static Label getTipTitleAsTextNode(Tip pTip) + private static Label getTipTitleAsLabel(Tip pTip) { assert pTip != null; @@ -273,11 +265,14 @@ private Node getTipElementAsNode(TipElement pTipElement, VBox pParent) Media media = pTipElement.getMedia(); if(media.equals(Media.TEXT)) { - return this.getTextTipElementAsTextNode(pTipElement); + return this.getTextTipElementAsLabel(pTipElement); } else // media.equals(Media.IMAGE) by @pre { - return getImageTipElementAsImageView(pTipElement); + HBox imageContainer = new HBox(getImageTipElementAsImageView(pTipElement)); + imageContainer.setAlignment(Pos.CENTER); + VBox.setMargin(imageContainer, IMAGE_PADDING); + return imageContainer; } } @@ -286,7 +281,7 @@ private Node getTipElementAsNode(TipElement pTipElement, VBox pParent) * @pre pTipElement != null * @pre pTipElement.getMedia().equals(Media.TEXT); */ - private Label getTextTipElementAsTextNode(TipElement pTipElement) + private Label getTextTipElementAsLabel(TipElement pTipElement) { assert pTipElement != null; assert pTipElement.getMedia().equals(Media.TEXT); @@ -308,7 +303,7 @@ private Label getTextTipElementAsTextNode(TipElement pTipElement) * @pre pTipElement != null * @pre pTipElement.getMedia().equals(Media.IMAGE) */ - private static HBox getImageTipElementAsImageView(TipElement pTipElement) + private static ImageView getImageTipElementAsImageView(TipElement pTipElement) { assert pTipElement != null; assert pTipElement.getMedia().equals(Media.IMAGE); @@ -326,11 +321,7 @@ private static HBox getImageTipElementAsImageView(TipElement pTipElement) // two times the padding because of the VBox padding, and a bit extra to make up for // other default spacing added between nodes } - HBox imageContainer = new HBox(imageNode); - imageContainer.setAlignment(Pos.CENTER); - VBox.setMargin(imageContainer, IMAGE_PADDING); - return imageContainer; - //return imageNode; + return imageNode; } catch( IOException e ) { diff --git a/test/org/jetuml/gui/tips/TestTipDialog.java b/test/org/jetuml/gui/tips/TestTipDialog.java index f7c601ba..b9d9ea1c 100644 --- a/test/org/jetuml/gui/tips/TestTipDialog.java +++ b/test/org/jetuml/gui/tips/TestTipDialog.java @@ -42,6 +42,7 @@ import javafx.event.ActionEvent; import javafx.scene.Node; import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; @@ -106,7 +107,7 @@ public void testGetTipElementAsNodeHandlesAllMedia() public void testGetTipTitleAsTextNodeGivesExpectedContent() { String title = aTip1.getTitle(); - Text titleNode = getTipTitleAsTextNode(aTip1); + Label titleNode = getTipTitleAsLabel(aTip1); assertEquals(title, titleNode.getText()); } @@ -127,7 +128,7 @@ public void testGetTipTitleAsTextNodeHasExpectedFontSize() } Tip tip = TipLoader.loadTip(1); - Text titleNode = getTipTitleAsTextNode(tip); + Label titleNode = getTipTitleAsLabel(tip); Font titleFont = titleNode.getFont(); assertEquals(fontSize, titleFont.getSize()); } @@ -199,7 +200,7 @@ public void testGetTextTipElementAsTextNodeReturnsValidTextNode() String content = "sample content"; TipElement tipElement = new TipElement(Media.TEXT, content); - Text node = getTextTipElementAsTextNode(aTipDialog, tipElement); + Label node = getTextTipElementAsLabel(aTipDialog, tipElement); assertNotNull(node); } @@ -210,9 +211,9 @@ public void testGetTextTipElementAsTextNodeReturnsNodeWithTextWrapAround() String content = "sample content"; TipElement tipElement = new TipElement(Media.TEXT, content); - Text node = getTextTipElementAsTextNode(aTipDialog, tipElement); + Label node = getTextTipElementAsLabel(aTipDialog, tipElement); - assertTrue(node.wrappingWidthProperty().isBound()); + assertTrue(node.isWrapText()); } @Test @@ -221,7 +222,7 @@ public void testGetTextTipElementAsTextNodeHasRightContent() String content = "sample content"; TipElement tipElement = new TipElement(Media.TEXT, content); - Text node = getTextTipElementAsTextNode(aTipDialog, tipElement); + Label node = getTextTipElementAsLabel(aTipDialog, tipElement); assertEquals(node.getText(), content); } @@ -329,13 +330,13 @@ private static Node getTipElementAsNode(TipDialog pImplicitTipDialog, TipElement } } - private static Text getTipTitleAsTextNode(Tip pTip) + private static Label getTipTitleAsLabel(Tip pTip) { try { - Method method = TipDialog.class.getDeclaredMethod("getTipTitleAsTextNode", Tip.class); + Method method = TipDialog.class.getDeclaredMethod("getTipTitleAsLabel", Tip.class); method.setAccessible(true); - return (Text) method.invoke(null, pTip); + return (Label) method.invoke(null, pTip); } catch(ReflectiveOperationException e) { @@ -418,13 +419,13 @@ private static void setupNewTip(TipDialog pImplicitTipDialog, Tip pTip) } } - private static Text getTextTipElementAsTextNode(TipDialog pImplicitTipDialog, TipElement pTipElement) + private static Label getTextTipElementAsLabel(TipDialog pImplicitTipDialog, TipElement pTipElement) { try { - Method method = TipDialog.class.getDeclaredMethod("getTextTipElementAsTextNode", TipElement.class); + Method method = TipDialog.class.getDeclaredMethod("getTextTipElementAsLabel", TipElement.class); method.setAccessible(true); - return (Text) method.invoke(pImplicitTipDialog, pTipElement); + return (Label) method.invoke(pImplicitTipDialog, pTipElement); } catch(ReflectiveOperationException e) {