From 39ef600e6ddd2ae9aa2dbb3210c0272256ff1365 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Mon, 28 Mar 2022 17:27:59 +0200 Subject: [PATCH] =?UTF-8?q?TP=2011=20d=C3=A9but?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APL2.1/TP11/Playlist/Playlist.java | 44 +++++++++++++++++++++++++ APL2.1/TP11/Playlist/TestPlaylist.java | 0 APL2.1/TP11/Volume/TestVolume.class | Bin 0 -> 701 bytes APL2.1/TP11/Volume/TestVolume.java | 17 ++++++++++ APL2.1/TP11/Volume/Volume.class | Bin 0 -> 1296 bytes APL2.1/TP11/Volume/Volume.java | 41 +++++++++++++++++++++++ 6 files changed, 102 insertions(+) create mode 100644 APL2.1/TP11/Playlist/Playlist.java create mode 100644 APL2.1/TP11/Playlist/TestPlaylist.java create mode 100644 APL2.1/TP11/Volume/TestVolume.class create mode 100644 APL2.1/TP11/Volume/TestVolume.java create mode 100644 APL2.1/TP11/Volume/Volume.class create mode 100644 APL2.1/TP11/Volume/Volume.java diff --git a/APL2.1/TP11/Playlist/Playlist.java b/APL2.1/TP11/Playlist/Playlist.java new file mode 100644 index 0000000..31ae505 --- /dev/null +++ b/APL2.1/TP11/Playlist/Playlist.java @@ -0,0 +1,44 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class Playlist extends JPanel implements MouseListener { + private JLabel prevSelection; + private JLabel prevHover; + + public void mouseClicked(MouseEvent evenement) { + JLabel raiser = evenement.getComponent(); + raiser.setBackground(new Color(0, 150, 255)); + + if (prevSelection != null) { + prevSelection.setBackground(new Color(255, 255, 255)); + } + } + + public void mouseEntered(MouseEvent evenement) { + + } + + public void mouseExited(MouseEvent evenement) { + + } + + public void mousePressed(MouseEvent evenement) {} + public void mouseReleased(MouseEvent evenement) {} + + @Override + public void paintComponent(Graphics brush) { + + } + + public Playlist() { + super(); + } + + public void add(String title) { + JLabel l = new JLabel(title); + l.addMouseListener(this); + l.setOpaque(true); + this.add(l); + } +} \ No newline at end of file diff --git a/APL2.1/TP11/Playlist/TestPlaylist.java b/APL2.1/TP11/Playlist/TestPlaylist.java new file mode 100644 index 0000000..e69de29 diff --git a/APL2.1/TP11/Volume/TestVolume.class b/APL2.1/TP11/Volume/TestVolume.class new file mode 100644 index 0000000000000000000000000000000000000000..1d0f2964efe1bb47fc6d8d4eb3c9837f80d0e995 GIT binary patch literal 701 zcmZuuO>fgc5Pj=7aq5`HDWomX0^uXrai}>UAt>S!6sgFihg7KwCnsLYR{p5`(IWm8 z7e}IqGvY@fW|K-m0$X}JJNxF%+nry(zx@F498YzuVnf4b9XE9-xFzAXge?i%8t&+* zV?)ASnYkySqv5`W2Mo1WA{O~;hKgm68Pq`%aE7KQV*aj(COkd#Cn06j$QLogy7j?3 z_0N4b^y3qEl&2y-*_DO*C@In@9|}os9`Y<7Ct(rs9mzJ(gvqcb=4o^;)yjF(LPTqJb4P1?QTAN?ZC2Vs)&gEO999jVrw-}ZxGKPfVP^ojG(6Isq< zo-%Z=I{Fv6%g=e7yZ^H0&r~4+hTdQFK@y!MF_rAv3)fO(nWWp2tFg$$Vhq-MdyEdQ z(a`0mfL9*TVo0OI}ZJ{k_8VbRpB7zl&P=X27;*^0edPy$H>Si}?b_?TY z{sf;G9hDisIfH@G89zJz5PyWjsL$DyP+>MXx#!&Hyglb^{`}|H-vOM)<~XMChJ!az zbg+z)h+__ID-ITLTuvuMltn!$r?*6`ih9b%+YWMg$Hu#&pLQ^f_iUW8@xH=nM@KC$ zP*7EcTqO*8u@2%b?I*@!YDd8dl1{~o8ouc%xQ!%=Oc2-1w(%9FI$_c?H`>Pd^>EuX z6_$#%FZH%A>$`E8m>@3KhmcF6pIzQk7^#F!L-(2&m}^PrwuwH|w|!bByV?ulO4#X! z0l^A;cg0(ebhqs_dTEH<^;kE)s_Sm*Y2z$=Ip+mlyry6kC5dxAOrnOl>`CB>trukPw>VHn|Mo@!n%Hi3y03Pa5E-WBGD zwwL`p2B*H5i#_U z{h2U@Im&4|0WM#(9Of~};ZM;rk3)l?inXSQ9~p17PG9>04y^EZtdH>(%i_u5ccKq> zMx-PK4Dm%P`!}x~Q zhtz+-5o$mI*=Ja^vG5Fs)#9GNQ6dq1BX&40F}xzoDLp}8!qyGUY))PYj literal 0 HcmV?d00001 diff --git a/APL2.1/TP11/Volume/Volume.java b/APL2.1/TP11/Volume/Volume.java new file mode 100644 index 0000000..af09c3a --- /dev/null +++ b/APL2.1/TP11/Volume/Volume.java @@ -0,0 +1,41 @@ +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + +public class Volume extends JComponent implements MouseWheelListener { + private static final int margin = 10; + private static final int numCircles = 10; + private int currentLevel = 0; + + public void mouseWheelMoved(MouseWheelEvent ev) { + currentLevel -= ev.getWheelRotation(); + currentLevel = Math.max(0, Math.min(currentLevel, 11)); + repaint(); + } + + @Override + protected void paintComponent(Graphics brush) { + Graphics newBrush = brush.create(); + + if (this.isOpaque()) { + newBrush.setColor(this.getBackground()); + newBrush.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + newBrush.setColor(new Color(50, 50, 50)); + newBrush.fillRect(0, 0, getWidth(), getHeight()); + + + for (int i = 0; i < numCircles; i++) { + if (currentLevel > i) newBrush.setColor(new Color(230, 170, 0)); + else newBrush.setColor(new Color(200, 200, 200)); + + newBrush.fillOval(margin + (getWidth() - margin * 2) / numCircles * i, getHeight() / 2, getHeight() / 4, getHeight() / 4); + } + } + + public Volume() { + super(); + } +} \ No newline at end of file