git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 1.2.0: better UI, some fixes
[fanfix.git]
/
src
/
be
/
nikiroo
/
fanfix
/
reader
/
LocalReaderBook.java
diff --git
a/src/be/nikiroo/fanfix/reader/LocalReaderBook.java
b/src/be/nikiroo/fanfix/reader/LocalReaderBook.java
index e7bea6aa5c80736661cc7a852000c57743030b8a..c716bd3aa47d75f3d3171aaf3d07f261c154bbad 100644
(file)
--- a/
src/be/nikiroo/fanfix/reader/LocalReaderBook.java
+++ b/
src/be/nikiroo/fanfix/reader/LocalReaderBook.java
@@
-59,17
+59,22
@@
class LocalReaderBook extends JPanel {
private static final int TEXT_WIDTH = COVER_WIDTH + 40;
private static final int TEXT_HEIGHT = 50;
private static final String AUTHOR_COLOR = "#888888";
private static final int TEXT_WIDTH = COVER_WIDTH + 40;
private static final int TEXT_HEIGHT = 50;
private static final String AUTHOR_COLOR = "#888888";
-
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
+
private JLabel icon;
private JLabel icon;
- private JLabel t
t
;
+ private JLabel t
itle
;
private boolean selected;
private boolean hovered;
private Date lastClick;
private long doubleClickDelay = 200; // in ms
private List<BookActionListener> listeners;
private boolean selected;
private boolean hovered;
private Date lastClick;
private long doubleClickDelay = 200; // in ms
private List<BookActionListener> listeners;
+ private String luid;
+ private boolean cached;
+
+ public LocalReaderBook(MetaData meta, boolean cached) {
+ this.luid = meta.getLuid();
+ this.cached = cached;
- public LocalReaderBook(MetaData meta) {
if (meta.getCover() != null) {
BufferedImage resizedImage = new BufferedImage(SPINE_WIDTH
+ COVER_WIDTH, SPINE_HEIGHT + COVER_HEIGHT + HOFFSET,
if (meta.getCover() != null) {
BufferedImage resizedImage = new BufferedImage(SPINE_WIDTH
+ COVER_WIDTH, SPINE_HEIGHT + COVER_HEIGHT + HOFFSET,
@@
-91,7
+96,7
@@
class LocalReaderBook extends JPanel {
if (optAuthor != null && !optAuthor.isEmpty()) {
optAuthor = "(" + optAuthor + ")";
}
if (optAuthor != null && !optAuthor.isEmpty()) {
optAuthor = "(" + optAuthor + ")";
}
- t
t
= new JLabel(
+ t
itle
= new JLabel(
String.format(
"<html>"
+ "<body style='width: %d px; height: %d px; text-align: center'>"
String.format(
"<html>"
+ "<body style='width: %d px; height: %d px; text-align: center'>"
@@
-102,7
+107,7
@@
class LocalReaderBook extends JPanel {
this.setLayout(new BorderLayout(10, 10));
this.add(icon, BorderLayout.CENTER);
this.setLayout(new BorderLayout(10, 10));
this.add(icon, BorderLayout.CENTER);
- this.add(t
t
, BorderLayout.SOUTH);
+ this.add(t
itle
, BorderLayout.SOUTH);
setupListeners();
setSelected(false);
setupListeners();
setSelected(false);
@@
-151,14
+156,16
@@
class LocalReaderBook extends JPanel {
}
public void mouseClicked(MouseEvent e) {
}
public void mouseClicked(MouseEvent e) {
- Date now = new Date();
- if (lastClick != null
- && now.getTime() - lastClick.getTime() < doubleClickDelay) {
- click(true);
- } else {
- click(false);
+ if (isEnabled()) {
+ Date now = new Date();
+ if (lastClick != null
+ && now.getTime() - lastClick.getTime() < doubleClickDelay) {
+ click(true);
+ } else {
+ click(false);
+ }
+ lastClick = now;
}
}
- lastClick = now;
}
});
}
}
});
}
@@
-177,6
+184,29
@@
class LocalReaderBook extends JPanel {
listeners.add(listener);
}
listeners.add(listener);
}
+ public String getLuid() {
+ return luid;
+ }
+
+ /**
+ * This boos is cached into the {@link LocalReader} library.
+ *
+ * @return the cached
+ */
+ public boolean isCached() {
+ return cached;
+ }
+
+ /**
+ * This boos is cached into the {@link LocalReader} library.
+ *
+ * @param cached
+ * the cached to set
+ */
+ public void setCached(boolean cached) {
+ this.cached = cached;
+ }
+
@Override
public void paint(Graphics g) {
super.paint(g);
@Override
public void paint(Graphics g) {
super.paint(g);
@@
-199,7
+229,8
@@
class LocalReaderBook extends JPanel {
g.fillPolygon(new Polygon(xs, ys, xs.length));
Color color = new Color(255, 255, 255, 0);
g.fillPolygon(new Polygon(xs, ys, xs.length));
Color color = new Color(255, 255, 255, 0);
- if (selected && !hovered) {
+ if (!isEnabled()) {
+ } else if (selected && !hovered) {
color = new Color(80, 80, 100, 40);
} else if (!selected && hovered) {
color = new Color(230, 230, 255, 100);
color = new Color(80, 80, 100, 40);
} else if (!selected && hovered) {
color = new Color(230, 230, 255, 100);
@@
-208,6
+239,11
@@
class LocalReaderBook extends JPanel {
}
Rectangle clip = g.getClipBounds();
}
Rectangle clip = g.getClipBounds();
+ if (cached) {
+ g.setColor(Color.green);
+ g.fillOval(clip.x + clip.width - 30, 10, 20, 20);
+ }
+
g.setColor(color);
g.fillRect(clip.x, clip.y, clip.width, clip.height);
}
g.setColor(color);
g.fillRect(clip.x, clip.y, clip.width, clip.height);
}