bookspanel: use full width for title
authorNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 19:17:01 +0000 (21:17 +0200)
committerNiki Roo <niki@nikiroo.be>
Sat, 25 Apr 2020 19:17:01 +0000 (21:17 +0200)
src/be/nikiroo/fanfix_swing/gui/book/BookBlock.java
src/be/nikiroo/fanfix_swing/gui/book/BookLine.java

index 183bd5768dd16df0d03ae43c3ff911051ac712a9..e77219bdb9026c138f1fa99599620226782a48d9 100644 (file)
@@ -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("<html>"
index 984a5b944bf495c1d347b24eb8fdd4228d5f31d7..6e4b6c2d5c44fd71532878658875566e827b54bb 100644 (file)
@@ -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) + "...";
                }