⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewer.java

📁 该系统是B/S结构的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                ivjPanel_Button.add(getbu_cut_end());
                getPanel_Button().add(getClear(), getClear().getName());
                ivjPanel_Button.add(getSpeed());
                ivjPanel_Button.add(getlabel_speed());
            }
            catch(Throwable throwable)
            {
                handleException(throwable);
            }
        return ivjPanel_Button;
    }

    private Panel getpanel_progress()
    {
        if(ivjpanel_progress == null)
            try
            {
                ivjpanel_progress = new Panel();
                ivjpanel_progress.setName("panel_progress");
                ivjpanel_progress.setLayout(new BorderLayout());
                ivjpanel_progress.setBackground(new Color(204, 204, 255));
                getpanel_progress().add(getlabel_progress(), "East");
                getpanel_progress().add(getProgress(), "Center");
            }
            catch(Throwable throwable)
            {
                handleException(throwable);
            }
        return ivjpanel_progress;
    }

    private ProgressBar getProgress()
    {
        if(ivjProgress == null)
            try
            {
                ivjProgress = new ProgressBar();
                ivjProgress.setName("Progress");
            }
            catch(Throwable throwable)
            {
                handleException(throwable);
            }
        return ivjProgress;
    }

    private ScrollPane getScroll()
    {
        if(ivjScroll == null)
            try
            {
                ivjScroll = new ScrollPane();
                ivjScroll.setName("Scroll");
            }
            catch(Throwable throwable)
            {
                handleException(throwable);
            }
        return ivjScroll;
    }

    private Scrollbar getSpeed()
    {
        if(ivjSpeed == null)
            try
            {
                ivjSpeed = new Scrollbar();
                ivjSpeed.setName("Speed");
                ivjSpeed.setMinimum(-1);
                ivjSpeed.setVisibleAmount(1);
                ivjSpeed.setValue(10);
                ivjSpeed.setBlockIncrement(1);
                ivjSpeed.setOrientation(0);
            }
            catch(Throwable throwable)
            {
                handleException(throwable);
            }
        return ivjSpeed;
    }

    private URL getURL()
    {
        try
        {
            String s = PTool.getStringDialog(null, ".pchか設定ファイルがある場所を指定してください(URL可)", null, "<ViewerURL>", "", "*.pch;*.cf", true);
            if(s == null || s.length() <= 0)
                return null;
            if(!s.startsWith("http://") && !s.startsWith("ftp://"))
            {
                file_last = new File(s);
                s = PTool.replaceText(s, '/', '\\');
                String s1 = "file://";
                if(s.charAt(0) != '/')
                    s1 = s1 + "/";
                s = s1 + s;
            }
            return new URL(s);
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
        return null;
    }

    private void handleException(Throwable throwable)
    {
    }

    private void in_switch(MgLine mgline)
    {
        try
        {
            lines.addElement(mgline);
            ivjProgress.setMax(lines.size());
            updateProgress();
            seek_need++;
        }
        catch(Throwable _ex) { }
    }

    private void inflate(MgLine mgline)
    {
        try
        {
            DataInputStream datainputstream = null;
            try
            {
                datainputstream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(mgline.getOffset()), new Inflater(false), mgline.getOffset().length));
                do
                {
                    MgLine mgline1 = new MgLine();
                    mgline1.setData(datainputstream);
                    if(mgline1.head == 103)
                        inflate(mgline1);
                    else
                        in_switch(mgline1);
                } while(true);
            }
            catch(EOFException _ex) { }
            catch(RuntimeException runtimeexception)
            {
                runtimeexception.printStackTrace();
            }
            if(datainputstream != null)
                datainputstream.close();
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
    }

    public void init()
    {
        try
        {
            super.init();
            setName("Viewer");
            setLayout(new BorderLayout());
            setSize(469, 240);
            add(getScroll(), "Center");
            add(getpanel_progress(), "North");
            add(getPanel_Button(), "South");
            initConnections();
            connEtoC5();
        }
        catch(Throwable throwable)
        {
            handleException(throwable);
        }
    }

    private void initConnections()
        throws Exception
    {
        getSpeed().addAdjustmentListener(this);
        getbu_play().addActionListener(this);
        getbu_stop().addActionListener(this);
        getcut_first().addActionListener(this);
        getbu_cut_end().addActionListener(this);
        getClear().addActionListener(this);
        getbu_load().addActionListener(this);
        getbu_save().addActionListener(this);
    }

    private void initViewer()
    {
        try
        {
            try
            {
                PProperties pproperties = ((ServerStub)getAppletContext()).getHashTable();
                newSize(pproperties.getInt("cx"), pproperties.getInt("cy"), Integer.decode(pproperties.getString("c", "#FFFFFF")).intValue());
            }
            catch(Throwable _ex)
            {
                Dimension dimension = getSize();
                newSize(dimension.width, dimension.height, 0xffffff);
            }
            MgLine.setup(this, 1);
            addNotify();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    public static void main(String args[])
    {
        try
        {
            Frame frame = new Frame();
            Class class1 = Class.forName("paintchat.viewer.Viewer");
            ClassLoader classloader = class1.getClassLoader();
            Viewer viewer = (Viewer)Beans.instantiate(classloader, "paintchat.viewer.Viewer");
            frame.add("Center", viewer);
            frame.setSize(viewer.getSize());
            frame.addWindowListener(new WindowAdapter() {

                public void windowClosing(WindowEvent windowevent)
                {
                    System.exit(0);
                }

            });
            frame.setVisible(true);
        }
        catch(Throwable throwable)
        {
            System.err.println("java.applet.Applet の main() で例外が発生しました");
            throwable.printStackTrace(System.out);
        }
    }

    public synchronized void newSize(int i, int j, int k)
    {
        int l = i * j;
        if(i_off == null || i_off[0].length < l)
            i_off = new int[2][l];
        k &= 0xffffff;
        for(int i1 = 0; i1 < l; i1++)
            i_off[0][i1] = k;

        System.arraycopy(i_off[0], 0, i_off[1], 0, l);
        image_x = i;
        image_y = j;
        Color color = new Color(k);
        if(display == null)
        {
            setBackground(color);
            display = new Canvas() {

                public void paint(Graphics g)
                {
                    try
                    {
                        if(image == null)
                            return;
                        g.drawImage(image, 0, 0, null);
                    }
                    catch(Throwable _ex) { }
                }

                public void update(Graphics g)
                {
                    paint(g);
                }

            };
            ivjScroll.add(display);
            addNotify();
        }
        display.setBackground(color);
        display.setSize(i, j);
        if(image != null)
        {
            offscreen.dispose();
            image.flush();
        }
        image = createImage(i, j);
        offscreen = image.getGraphics();
        offscreen.setColor(color);
        offscreen.fillRect(0, 0, i, j);
    }

    private synchronized void playAnimation()
    {
        try
        {
            stopAnimation();
            if(seek > seek_need)
            {
                clear();
                seek = 0;
            }
            live_draw = true;
            t_draw = new Thread(this, "d");
            t_draw.setPriority(1);
            t_draw.setDaemon(true);
            t_draw.start();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    private synchronized void playLoad()
    {
        try
        {
            stopLoad();
            live_load = true;
            t_load = new Thread(this, "l");
            t_load.setPriority(1);
            t_load.setDaemon(true);
            t_load.start();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    public void run()
    {
        try
        {
            switch(Thread.currentThread().getName().charAt(0))
            {
            case 108: // 'l'
                run_load();
                break;

            case 100: // 'd'
                run_draw();
                break;
            }
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    private void run_draw()
        throws InterruptedException
    {
        int[] _tmp = new int[16384];
        try
        {
            Graphics g = display.getGraphics();
            while(live_draw) 
            {
                while(seek < seek_need && live_draw) 
                    try
                    {
                        MgLine mgline = (MgLine)lines.elementAt(seek++);
                        mgline.setVisit(255, 255);
                        ivjProgress.setValue(seek);
                        updateProgress();
                        mgline.draw(display, g, offscreen, i_off, image_x, image_y, 0, 0, 1, 255, 255, speed);
                        if(speed > 0)
                            Thread.sleep(speed);
                    }
                    catch(RuntimeException runtimeexception)
                    {
                        runtimeexception.printStackTrace();
                    }
                if(live_draw)
                    Thread.sleep(1000L);
            }
        }
        catch(InterruptedException _ex) { }
    }

    private void run_load()
    {
        DataInputStream datainputstream = null;
        try
        {
            URL url = getURL();
            if(url == null)
                return;
            datainputstream = new DataInputStream(new GZIPInputStream(url.openStream(), 4096));
            try
            {
                while(live_load) 
                {
                    MgLine mgline = new MgLine();
                    mgline.setData(datainputstream);
                    if(mgline.head == 103)
                        inflate(mgline);
                    else
                        in_switch(mgline);
                }
            }
            catch(EOFException _ex) { }
        }
        catch(Throwable _ex) { }
        if(datainputstream != null)
            try
            {
                datainputstream.close();
            }
            catch(IOException _ex) { }
    }

    public void start()
    {
        try
        {
            if(lines != null)
                return;
            lines = new Vector();
            initViewer();
            playAnimation();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    private synchronized void stopAnimation()
    {
        try
        {
            live_draw = false;
            if(t_draw != null)
            {
                t_draw.interrupt();
                t_draw.join();
                t_draw = null;
            }
            updateValues();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    private synchronized void stopLoad()
    {
        try
        {
            live_load = false;
            if(t_load != null)
            {
                t_load.interrupt();
                t_load.join();
                t_load = null;
            }
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    public void updateProgress()
    {
        ivjlabel_progress.setText(String.valueOf(seek) + '/' + lines.size());
        ivjlabel_progress.invalidate();
        ivjlabel_progress.validate();
    }

    public void updateSpeed(AdjustmentEvent adjustmentevent)
    {
        speed = adjustmentevent.getValue();
        ivjlabel_speed.setText("Speed[" + speed + "]");
        ivjlabel_speed.invalidate();
        updateProgress();
        ivjPanel_Button.doLayout();
    }

    public void updateValues()
    {
        try
        {
            ivjlabel_speed.setText("Speed[" + speed + ']');
            updateProgress();
        }
        catch(Throwable throwable)
        {
            throwable.printStackTrace();
        }
    }

    public void viewer_Init()
    {
        ivjProgress.inits(0, 0, 0, 0);
        ivjProgress.addListener(this);
    }

    public Viewer()
    {
        live = true;
        live_draw = false;
        live_load = false;
        lines = null;
        i_off = null;
        display = null;
        image = null;
        speed = 10;
        seek = 0;
        seek_need = 0;
        file_last = null;
        ivjbu_cut_end = null;
        ivjbu_play = null;
        ivjbu_stop = null;
        ivjcut_first = null;
        ivjScroll = null;
        ivjSpeed = null;
        ivjLabel6 = null;
        ivjlabel_speed = null;
        ivjPanel_Button = null;
        ivjpanel_progress = null;
        ivjProgress = null;
        ivjClear = null;
        ivjlabel_progress = null;
        ivjbu_load = null;
        ivjbu_save = null;
        ivjLabel1 = null;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -