From: Niki Roo Date: Sat, 25 Apr 2020 19:17:01 +0000 (+0200) Subject: bookspanel: use full width for title X-Git-Tag: fanfix-swing-1.0.0~32 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=0a22b65f7c97821ce232af2f2fa0d4f343387379;p=fanfix-swing.git bookspanel: use full width for title --- diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java b/src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java index 183bd576..e77219bd 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java @@ -79,8 +79,8 @@ public class BookBlock extends BookLine { @Override protected void updateMeta() { - String main = getMainInfoDisplay(); - String optSecondary = getSecondaryInfoDisplay(isSeeWordCount()); + String main = getMainInfoDisplay(true); + String optSecondary = getSecondaryInfoDisplay(isSeeWordCount(), true); String color = String.format("#%X%X%X", AUTHOR_COLOR.getRed(), AUTHOR_COLOR.getGreen(), AUTHOR_COLOR.getBlue()); title.setText(String.format("" diff --git a/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java b/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java index 984a5b94..6e4b6c2d 100644 --- a/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java +++ b/src/be/nikiroo/fanfix_swing/gui/book/BookLine.java @@ -176,10 +176,13 @@ public class BookLine extends JPanel { /** * Return a display-ready version of {@link BookInfo#getMainInfo()}. * + * @param limit + * TRUE to allow shortening + * * @return the main info in a ready-to-display version */ - protected String getMainInfoDisplay() { - return toDisplay(getInfo().getMainInfo()); + protected String getMainInfoDisplay(boolean limit) { + return toDisplay(getInfo().getMainInfo(), limit); } /** @@ -188,19 +191,21 @@ public class BookLine extends JPanel { * * @param seeCount * TRUE for word/image/story count, FALSE for author name + * @param limit + * TRUE to allow shortening * * @return the main info in a ready-to-display version */ - protected String getSecondaryInfoDisplay(boolean seeCount) { - return toDisplay(getInfo().getSecondaryInfo(seeCount)); + protected String getSecondaryInfoDisplay(boolean seeCount, boolean limit) { + return toDisplay(getInfo().getSecondaryInfo(seeCount), limit); } /** * Update the title with the currently registered information. */ protected void updateMeta() { - String main = getMainInfoDisplay(); - String optSecondary = getSecondaryInfoDisplay(isSeeWordCount()); + String main = getMainInfoDisplay(false); + String optSecondary = getSecondaryInfoDisplay(isSeeWordCount(), false); title.setText(main); secondary.setText(optSecondary + " "); @@ -221,14 +226,16 @@ public class BookLine extends JPanel { * * @param value * the full value + * @param limit + * TRUE to allow shortening * * @return the display-ready value */ - private String toDisplay(String value) { + private String toDisplay(String value, boolean limit) { if (value == null) value = ""; - if (value.length() > MAX_DISPLAY_SIZE) { + if (limit && value.length() > MAX_DISPLAY_SIZE) { value = value.substring(0, MAX_DISPLAY_SIZE - 3) + "..."; }