Skip to content

Commit

Permalink
new slideshow features - now works with remote
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhare committed Jul 31, 2018
1 parent 879e882 commit b849a26
Showing 1 changed file with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public abstract class Slideshow implements KeyListener {

private JPanel contentPanel;

private boolean hidden = false;

/**
* Default constructor.
*
Expand All @@ -86,13 +88,14 @@ public abstract class Slideshow implements KeyListener {
* @param slideHeight
* the height to display the slides
* @param background
* a background image to display behind the slides (the slides
* need to be transparent!)
* a background image to display behind the slides (the slides need
* to be transparent!)
* @throws IOException
* if the first slide can't be loaded
*/
public Slideshow(RootPaneContainer container, List<Slide> slides, final int slideWidth, final int slideHeight,
BufferedImage background) throws IOException
BufferedImage background)
throws IOException
{
this.container = container;

Expand All @@ -113,11 +116,16 @@ public Slideshow(RootPaneContainer container, List<Slide> slides, final int slid
private static final long serialVersionUID = 1L;

@Override
public void paintComponent(Graphics g)
{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(bg, 0, 0, slideWidth, slideHeight, null);
};

@Override
public void paint(Graphics g) {
if (!hidden)
super.paint(g);
}
};
contentPanel.setOpaque(false);
contentPanel.setSize(slideWidth, slideHeight);
Expand Down Expand Up @@ -213,17 +221,38 @@ public void keyPressed(KeyEvent e) {
try {
switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT:
displayPrevSlide();
if (!hidden)
displayPrevSlide();
break;
case KeyEvent.VK_PAGE_UP:
if (!hidden)
displayPrevSlide();
break;
case KeyEvent.VK_RIGHT:
displayNextSlide();
if (!hidden)
displayNextSlide();
break;
case KeyEvent.VK_PAGE_DOWN:
if (!hidden)
displayNextSlide();
break;
case KeyEvent.VK_F:
toggleFullscreen();
break;
case KeyEvent.VK_F5:
if (e.isShiftDown())
toggleFullscreen();
break;
case KeyEvent.VK_ESCAPE:
setFullscreen(false);
break;
case KeyEvent.VK_B:
System.out.println(this.hidden);
if (!e.isShiftDown()) {
this.hidden = !this.hidden;
this.contentPanel.repaint();
}
break;
case KeyEvent.VK_Q:
System.exit(0);
}
Expand Down

0 comments on commit b849a26

Please sign in to comment.