diff --git a/resources/uk/co/majenko/audiobookrecorder/icons/book.png b/resources/uk/co/majenko/audiobookrecorder/icons/book.png index a2a8e42..51da4d0 100644 Binary files a/resources/uk/co/majenko/audiobookrecorder/icons/book.png and b/resources/uk/co/majenko/audiobookrecorder/icons/book.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/icons/chapter.png b/resources/uk/co/majenko/audiobookrecorder/icons/chapter.png index 6e2cc42..79ed4ce 100644 Binary files a/resources/uk/co/majenko/audiobookrecorder/icons/chapter.png and b/resources/uk/co/majenko/audiobookrecorder/icons/chapter.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/icons/sentence.png b/resources/uk/co/majenko/audiobookrecorder/icons/sentence.png index 2bbe07e..1737e2f 100644 Binary files a/resources/uk/co/majenko/audiobookrecorder/icons/sentence.png and b/resources/uk/co/majenko/audiobookrecorder/icons/sentence.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/overlays/attention.png b/resources/uk/co/majenko/audiobookrecorder/overlays/attention.png new file mode 100644 index 0000000..1953702 Binary files /dev/null and b/resources/uk/co/majenko/audiobookrecorder/overlays/attention.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/overlays/filter.png b/resources/uk/co/majenko/audiobookrecorder/overlays/filter.png new file mode 100644 index 0000000..c849630 Binary files /dev/null and b/resources/uk/co/majenko/audiobookrecorder/overlays/filter.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/overlays/important.png b/resources/uk/co/majenko/audiobookrecorder/overlays/important.png new file mode 100644 index 0000000..be267cb Binary files /dev/null and b/resources/uk/co/majenko/audiobookrecorder/overlays/important.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/overlays/locked.png b/resources/uk/co/majenko/audiobookrecorder/overlays/locked.png new file mode 100644 index 0000000..ef5f9c7 Binary files /dev/null and b/resources/uk/co/majenko/audiobookrecorder/overlays/locked.png differ diff --git a/resources/uk/co/majenko/audiobookrecorder/overlays/star.png b/resources/uk/co/majenko/audiobookrecorder/overlays/star.png new file mode 100644 index 0000000..1d40cc6 Binary files /dev/null and b/resources/uk/co/majenko/audiobookrecorder/overlays/star.png differ diff --git a/src/uk/co/majenko/audiobookrecorder/BookTreeRenderer.java b/src/uk/co/majenko/audiobookrecorder/BookTreeRenderer.java index f061202..659d64f 100644 --- a/src/uk/co/majenko/audiobookrecorder/BookTreeRenderer.java +++ b/src/uk/co/majenko/audiobookrecorder/BookTreeRenderer.java @@ -11,25 +11,31 @@ public class BookTreeRenderer extends DefaultTreeCellRenderer { if (value instanceof Sentence) { Sentence s = (Sentence)value; + OverlayIcon icn = new OverlayIcon(Icons.sentence); + if (s.getOverrideText() != null) { ret.setText(s.getOverrideText()); } if (s.getAttentionFlag()) { ret.setForeground(new Color(0xFF, 0xFF, 0x00)); - ret.setIcon(Icons.attention); - } else if (s.isLocked()) { + icn.add(Overlays.attention, OverlayIcon.TOP_LEFT); + } + + if (s.isLocked()) { ret.setForeground(new Color(0x00, 0x80, 0xFF)); - ret.setIcon(Icons.locked); - } else if (s.getStartOffset() == 0) { - ret.setIcon(Icons.important); - } else { - ret.setIcon(Icons.sentence); + icn.add(Overlays.locked, OverlayIcon.BOTTOM_LEFT); + } + + if (s.getStartOffset() == 0) { + icn.add(Overlays.important, OverlayIcon.TOP_RIGHT); + } + + if (s.getEthereal()) { + icn.add(Overlays.filter, OverlayIcon.BOTTOM_RIGHT); } - if (s.isInSample()) { - ret.setIcon(Icons.star); - } + ret.setIcon(icn); } else if (value instanceof Chapter) { ret.setIcon(Icons.chapter); diff --git a/src/uk/co/majenko/audiobookrecorder/OverlayIcon.java b/src/uk/co/majenko/audiobookrecorder/OverlayIcon.java new file mode 100644 index 0000000..6e295b1 --- /dev/null +++ b/src/uk/co/majenko/audiobookrecorder/OverlayIcon.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2015, Majenko Technologies + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * * Neither the name of Majenko Technologies nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package uk.co.majenko.audiobookrecorder; + +import javax.swing.ImageIcon; +import java.util.List; +import java.util.ArrayList; +import java.awt.Component; +import java.awt.Graphics; + +public class OverlayIcon extends ImageIcon { + class IconSpec { + public ImageIcon icon; + int location; + + public IconSpec(ImageIcon i, int loc) { + icon = i; + location = loc; + } + } + + private ImageIcon base; + private ArrayList overlays; + + public static final int TOP_LEFT = 0; + public static final int TOP_MIDDLE = 1; + public static final int TOP_RIGHT = 2; + public static final int MIDDLE_LEFT = 3; + public static final int MIDDLE_MIDDLE = 4; + public static final int MIDDLE_RIGHT = 5; + public static final int BOTTOM_LEFT = 6; + public static final int BOTTOM_MIDDLE = 7; + public static final int BOTTOM_RIGHT = 8; + + public OverlayIcon(ImageIcon base) { + super(base.getImage()); + this.base = base; + this.overlays = new ArrayList(); + } + + public void add(ImageIcon overlay, int position) { + overlays.add(new IconSpec(overlay, position)); + } + + @Override + + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { + base.paintIcon(c, g, x, y); + + int bw = base.getIconWidth(); + int bh = base.getIconHeight(); + + for(IconSpec icon : overlays) { + int iw = icon.icon.getIconWidth(); + int ih = icon.icon.getIconHeight(); + + int ix = 0; + int iy = 0; + + switch (icon.location) { + case TOP_LEFT: + case MIDDLE_LEFT: + case BOTTOM_LEFT: + ix = 0; + break; + + case TOP_MIDDLE: + case MIDDLE_MIDDLE: + case BOTTOM_MIDDLE: + ix = (bw / 2) - (iw / 2); + break; + + case TOP_RIGHT: + case MIDDLE_RIGHT: + case BOTTOM_RIGHT: + ix = bw - iw; + break; + } + + switch (icon.location) { + case TOP_LEFT: + case TOP_MIDDLE: + case TOP_RIGHT: + iy = 0; + break; + + case MIDDLE_LEFT: + case MIDDLE_MIDDLE: + case MIDDLE_RIGHT: + iy = (bh / 2) - (ih / 2); + break; + + case BOTTOM_LEFT: + case BOTTOM_MIDDLE: + case BOTTOM_RIGHT: + iy = bh - ih; + break; + } + + icon.icon.paintIcon(c, g, x + ix, y + iy); + } + } +} diff --git a/src/uk/co/majenko/audiobookrecorder/Overlays.java b/src/uk/co/majenko/audiobookrecorder/Overlays.java new file mode 100644 index 0000000..3a42d4d --- /dev/null +++ b/src/uk/co/majenko/audiobookrecorder/Overlays.java @@ -0,0 +1,11 @@ +package uk.co.majenko.audiobookrecorder; + +import javax.swing.*; + +public class Overlays { + static public final ImageIcon locked = new ImageIcon(Overlays.class.getResource("overlays/locked.png")); + static public final ImageIcon star = new ImageIcon(Overlays.class.getResource("overlays/star.png")); + static public final ImageIcon important = new ImageIcon(Overlays.class.getResource("overlays/important.png")); + static public final ImageIcon attention = new ImageIcon(Overlays.class.getResource("overlays/attention.png")); + static public final ImageIcon filter = new ImageIcon(Overlays.class.getResource("overlays/filter.png")); +}