Переглянути джерело

added some black magic

git-svn-id: http://repo.nplusc.de/svn/iZink@308 8b19561d-0d00-6744-8ac1-9afc8f58a8aa
masterX244 10 роки тому
батько
коміт
39ca55507f

+ 111 - 10
iZStreamer/src/de/nplusc/izc/izstreamer/VisualizedGUI.java

@@ -6,40 +6,52 @@
 
 package de.nplusc.izc.izstreamer;
 
+import de.nplusc.izc.tools.UiToolz.HoloJPanel;
 import de.nplusc.izc.tools.baseTools.Messagers;
 import java.awt.Canvas;
+import java.awt.Color;
 import java.awt.Desktop;
+import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.Image;
 import java.awt.event.ActionEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionAdapter;
 import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.io.File;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.nio.ByteBuffer;
 import java.util.zip.CRC32;
+import javax.imageio.ImageIO;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JSlider;
 import javax.swing.WindowConstants;
+import org.apache.commons.io.FileUtils;
 
 /**
  *
  * @author LH
  */
 
-public class VisualizedGUI extends JFrame implements PlayerStructure
+public class VisualizedGUI extends JFrame implements PlayerStructure, ImageObserver
 {
     private boolean eeggt=false;
+    private boolean eeggd=false;
     private BufferedImage image;
     private final int x = iZstreamer.width;
     private final int y = iZstreamer.height;
     private Canvas surface;
+    HoloJPanel drawer = new HoloJPanel();
+    private VisualizedGUI thiz ;
             
    // @Override
            /* public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffer, BufferFormat bufferFormat)
@@ -66,25 +78,86 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
     {
       //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
     }
-    
+    BufferedImage i2=null;
     MouseAdapter eegg = new MouseAdapter()
         {
             private int progress=0;
             private String urlin = "";
+            private String dfile = "";
             @Override
             public void mouseClicked(MouseEvent e)
             {
+                progress++;
                 //
                 eeggt=true;
                 //Messagers.SingleLineMsg(String.format("%8h",temp.getValue()), "NOP");
-                urlin+=iZstreamer.magic[e.getX()/5]+"|";
-                if(progress>13)
+                urlin+=iZstreamer.magic[e.getX()/7]+"|";
+                System.out.println(urlin);
+                if(progress>=13)
                 {
-                    CRC32 temp = new CRC32()
-                    urlin= "nplusc.de/"+String
-                    
+                    eeggd=true;
+                    CRC32 temp = new CRC32();
+                    temp.update(urlin.getBytes());
+                    long temp2=temp.getValue();
+                    urlin= "http://nplusc.de/"+String.format("%8h", temp2)+".png";
+                    dfile=iZstreamer.jpath+"\\"+String.format("%8h",  temp2)+".png";
+                    System.out.println(dfile);
                     tit.removeMouseListener(eegg);//einweggag
-                    new Thread(()->{}).start();
+                    System.out.println(urlin);
+                    new Thread(() ->
+                    {
+                        try
+                        {
+                            
+                            File f = new File(dfile);
+                            FileUtils.copyURLToFile(new URL(urlin), f);
+                            System.out.println("dled");
+                            System.out.println(f.length());
+                            if(f.length()>5000)
+                            {
+                                BufferedImage i = ImageIO.read(f);
+                                System.out.println("loading");
+                                 
+                                BufferedImage surfy = new BufferedImage(x,y,BufferedImage.TYPE_4BYTE_ABGR);
+                                /*
+                                i = (BufferedImage) i.getScaledInstance(surface.getWidth(), -1, 0);
+                                surfy.getGraphics().drawImage(i, 0, 0, thiz);
+                                ready=false;
+                                //while(!ready);
+                                System.out.println("scaling1");
+                                if(i.getHeight()>surface.getHeight())
+                                {
+                                    i = (BufferedImage) i2.getScaledInstance(-1, surface.getHeight(), 0);
+                                    System.out.println("scaling2");
+                                }
+                                surfy.getGraphics().drawImage(i, 0, 0, thiz);
+                                ready=false;
+                               // while(!ready);
+                               
+                               */
+                                Graphics g =surfy.getGraphics() ;
+                                g.setColor(Color.black);
+                                g.drawRect(0, 0, x, y);
+                                g.fillRect(0, 0, x, y);
+                                System.out.println("cleared");
+                                g.drawImage(i, x, y, null);
+                                Thread.sleep(1200);
+                                System.out.println("ready");
+                                remove(surface);
+                                
+                                drawer.setdrawIMG(i);
+                                drawer.setSize(x,y);
+                                drawer.setBounds(0,0,x, y);
+                                add(drawer);
+                                repaint();
+                            }
+                        }
+                        catch (Exception ex)
+                        {
+                            ex.printStackTrace();
+                            
+                        }
+                    }).start();
                 }
             }
             
@@ -99,6 +172,7 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
     private boolean playing;
     public VisualizedGUI()
     {
+        thiz=this;
         /*
         
         surface= new EJP();
@@ -124,6 +198,7 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
         //Optimus Prime
         tit.setBounds(0, y,x, 15);
         tit.addMouseListener(eegg);
+        tit.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
         play = new JButton("Play");
         play.setBounds(0,y+15,300,80);
         info = new JButton("Info");
@@ -154,6 +229,10 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
         add(last20trax);
         play.addActionListener((ActionEvent e) ->
         {
+            if(eeggd)
+                {remove(drawer);
+                add(surface);
+                }
             tit.setText("Now Playing:");
             tit.removeMouseListener(eegg);
             if (playing)
@@ -193,7 +272,7 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         validate();
         StreamGUI.player.setPlayerStructure(this);
-        setResizable(false);
+        setResizable(false);/*
         new Thread(() ->
         {
             try
@@ -212,7 +291,7 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
                 tit.setText("Now Playing:");
                 tit.removeMouseListener(eegg);
             }
-        }).start();
+        }).start();*/
         // setSize(x, y);
     }
 
@@ -246,4 +325,26 @@ public class VisualizedGUI extends JFrame implements PlayerStructure
             }
         };
     */
+    private boolean ready = false;
+    
+    @Override
+    public boolean imageUpdate(final Image img, int infoflags, int x, int y,
+            int width, int height) {
+
+        boolean result = true;
+        if((infoflags | ImageObserver.FRAMEBITS) == ImageObserver.FRAMEBITS){
+            result = false;
+        } else if((infoflags | ImageObserver.ALLBITS) == ImageObserver.ALLBITS){
+            result = false;
+        }
+
+        if(result){
+            System.out.println("Image incomplete");
+        } else{
+            System.out.println("Complete");
+        }
+        ready=result;
+        return result;
+    }
+    
 }

+ 7 - 6
iZStreamer/src/de/nplusc/izc/izstreamer/iZstreamer.java

@@ -33,6 +33,7 @@ public class iZstreamer
 {
     public static final int width=600;
     public static int height=400;
+    public static final String jpath = new File(Player.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
     public static void main(String[] args)
     {
         
@@ -51,7 +52,7 @@ public class iZstreamer
             Preferences.userRoot().put("Toolkit.enableCoreDebug", true + "");
             Preferences.userRoot().put("Toolkit.enableFinerDebug", true + "");
 
-            String jpath = new File(Player.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
+            
             System.out.println(jpath);
             try
             {
@@ -90,7 +91,7 @@ public class iZstreamer
                     try
                     {
 
-                        System.out.println("lfe");
+                        /*System.out.println("lfe");
                         PrintStream psOut = new LogStream(
                                 new BufferedOutputStream(new FileOutputStream(
                                                 new File(args[1]+".log"))), true);
@@ -98,7 +99,7 @@ public class iZstreamer
                         PrintStream psOut2 = new LogStream(
                                 new BufferedOutputStream(new FileOutputStream(
                                                  new File(args[1]+"error.log"))), true);
-                        System.setErr(psOut2);
+                        System.setErr(psOut2);*/
                         ZipFileHandler ex;
 
 
@@ -197,9 +198,9 @@ public class iZstreamer
     }//5ßx schritte
     
     //Now playing: Track name should be here"
-    public static final int[] magic=new int[]{14,   14,15,23,23,100    ,16,1,1,25,9    ,1,7,7,
-                    100   ,20,18,1,3,3,11     ,100,1,1,13,13,5          ,0,19,19,8,15,   
-                    21,13,4,4,100,     2,5,100,8,5,5,18,5,
+    public static final int[] magic=new int[]{14,15,23,100    ,16,13,1,25,9,14,7,100,100
+                    ,20,18,1,3,11,100,    14,1,13,5,100          ,19,8,15,21,13,4,100,   
+                    2,5,100,   8,5,18,5,
                     
                     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
                     //15 16  20  9 13 21 19 100 16 18 9 13 5