sltv team mailing list archive
-
sltv team
-
Mailing list archive
-
Message #00029
[Branch ~sltv/sltv/trunk] Rev 21: Drawing png logo location over video.
------------------------------------------------------------
revno: 21
committer: lucasa@xxxxxxxxx
branch nick: sltv
timestamp: Tue 2009-12-01 18:22:08 -0200
message:
Drawing png logo location over video.
added:
src/br/org/softwarelivre/sltv/DrawingGlassPane.java
--
lp:sltv
https://code.launchpad.net/~sltv/sltv/trunk
Your team sltv is subscribed to branch lp:sltv.
To unsubscribe from this branch go to https://code.launchpad.net/~sltv/sltv/trunk/+edit-subscription.
=== added file 'src/br/org/softwarelivre/sltv/DrawingGlassPane.java'
--- src/br/org/softwarelivre/sltv/DrawingGlassPane.java 1970-01-01 00:00:00 +0000
+++ src/br/org/softwarelivre/sltv/DrawingGlassPane.java 2009-12-01 20:22:08 +0000
@@ -0,0 +1,76 @@
+package br.org.softwarelivre.sltv;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+
+import javax.swing.JComponent;
+
+class DrawingGlassPane extends JComponent implements MouseMotionListener {
+
+ private Point lastMouseLocation = new Point(0, 0);
+
+ public DrawingGlassPane() {
+ setBackground(Color.WHITE);
+ addMouseMotionListener(this);
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ // enables anti-aliasing
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+
+ // gets the current clipping area
+ Rectangle area = g.getClipBounds();
+
+ // sets a 65% translucent composite
+ AlphaComposite alpha = AlphaComposite.SrcOver.derive(0.1f);
+ Composite composite = g2.getComposite();
+ g2.setComposite(alpha);
+
+ // fills the background
+ g2.setColor(getBackground());
+ g2.fillRect(area.x, area.y, area.width, area.height);
+
+ int width = 100;
+ int height = 100;
+
+ // draws the content of the progress bar
+ //Paint paint = g2.getPaint();
+
+ //g2.setPaint(paint);
+ g2.setColor(Color.BLACK);
+ System.out.println("Mouse: "+this.getLastMouseLocation());
+ // draws the progress bar border
+ g2.drawRect((int)this.getLastMouseLocation().getX(), (int)this.getLastMouseLocation().getY()-height, width, height);
+
+ g2.setComposite(composite);
+ }
+
+ public void mouseDragged(MouseEvent e) { }
+
+ public void mouseMoved(MouseEvent e)
+ {
+ setLastMouseLocation(e.getLocationOnScreen());
+ this.repaint();
+ }
+
+ public Point getLastMouseLocation()
+ {
+ return lastMouseLocation;
+ }
+
+ public void setLastMouseLocation(Point lastMouseLocation)
+ {
+ this.lastMouseLocation = lastMouseLocation;
+ }
+}
\ No newline at end of file