Added overlay icons
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 838 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 263 B |
|
Before Width: | Height: | Size: 799 B After Width: | Height: | Size: 710 B |
BIN
resources/uk/co/majenko/audiobookrecorder/overlays/attention.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
resources/uk/co/majenko/audiobookrecorder/overlays/filter.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
resources/uk/co/majenko/audiobookrecorder/overlays/important.png
Normal file
|
After Width: | Height: | Size: 262 B |
BIN
resources/uk/co/majenko/audiobookrecorder/overlays/locked.png
Normal file
|
After Width: | Height: | Size: 256 B |
BIN
resources/uk/co/majenko/audiobookrecorder/overlays/star.png
Normal file
|
After Width: | Height: | Size: 301 B |
@@ -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);
|
||||
|
||||
131
src/uk/co/majenko/audiobookrecorder/OverlayIcon.java
Normal file
@@ -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<IconSpec> 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<IconSpec>();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/uk/co/majenko/audiobookrecorder/Overlays.java
Normal file
@@ -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"));
|
||||
}
|
||||