Algorithm-VSM

 view release on metacpan or  search on metacpan

examples/corpus/EventThreadDemo.java  view on Meta::CPAN

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;

class EventThreadDemo {

    public static void main( String[] args ) {

        JFrame frame = new JFrame( "Event Thread Demo" );

        frame.addWindowListener( new WindowAdapter() {
                public void windowClosing( WindowEvent e ) {
                    System.exit( 0 );
                }
        });

        JTextArea textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.getDocument().addDocumentListener(
                                 new MyDocumentListener());

examples/corpus/EventThreadDemo.java  view on Meta::CPAN

        areaScrollPane.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane.setPreferredSize(new Dimension(250, 250));
        areaScrollPane.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5,5,5,5)),
                areaScrollPane.getBorder()));
        
        frame.getContentPane().add( 
                       areaScrollPane, BorderLayout.CENTER );
        frame.pack();
        frame.setVisible( true );
        keepBusy( 500, "main" );                                  //(A)
    }

    static class MyDocumentListener implements DocumentListener {
        public void insertUpdate( final DocumentEvent e ) {
            String str = null;
            Document doc = e.getDocument();
            int lengthText = doc.getLength();
            try {
                str = doc.getText( lengthText - 1, 1 );

examples/corpus/EventThreadDemo2.java  view on Meta::CPAN

    }
}

////////////////////////  class LaunchFrame  /////////////////////////
class LaunchAFrame extends Thread {                               //(E)
    public LaunchAFrame() {}

    public void run() {                                           //(F)
        MyTools.printThreadInfo(                                  //(G)
                 "Just before creating Frame object:" );
        JFrame frame = new JFrame( "EventThreadsDemo 2" );        //(H)
        MyTools.printThreadInfo( 
                 "Just after creating Frame object:" );
        frame.addWindowListener( new WindowAdapter() {        
                public void windowClosing( WindowEvent e ) {
                    System.exit( 0 );
                }
        });
        JTextArea textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.getDocument().addDocumentListener(
                                new MyDocumentListener());
        MyTools.printThreadInfo(                                  //(I)

examples/corpus/EventThreadDemo2.java  view on Meta::CPAN


        areaScrollPane.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane.setPreferredSize(new Dimension(250, 250));
        areaScrollPane.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5,5,5,5)),
                areaScrollPane.getBorder()));
        frame.getContentPane().add( 
                       areaScrollPane, BorderLayout.CENTER );
        MyTools.printThreadInfo( "Just before calling pack:" );
        frame.pack();
        frame.setLocation( 300, 300 );
        frame.setVisible( true );
        MyTools.printThreadInfo("Just after calling setVisible:");//(K)     
    }
}

///////////////////////////  class MyTools  ///////////////////////////
class MyTools {                                                   //(L)
    public static void printThreadInfo( String s ) {              //(M)
        System.out.println( s );
//        Thread.currentThread().getThreadGroup().list();
//        System.out.println( 

examples/corpus/SlideShowApplet.java  view on Meta::CPAN



//SlideShowApplet.java

import javax.swing.*;
import java.awt.*;             //for Graphics, Color, Dimension, etc.
import java.awt.event.*;
import java.net.*;             //for URL needed for image loading

public class SlideShowApplet extends JApplet {                    //(B)
    int frameIndex = 0;        //current frame number
    String dir;                //directory relative to the codebase 
    Timer timer;               //timer for sequencing through images      
    int pause;                 //time interval between images
    int numImages;             //number of images to display
    int width;                 //width of the applet
    int height;                //height of the applet
    int displayWidth;
    int displayHeight;
    JComponent contentPane;    //the applet's content pane
    ImageIcon images[];        //the images

examples/corpus/SlideShowApplet.java  view on Meta::CPAN

        displayWidth = width - getInsets().left - getInsets().right;
        displayHeight = height - getInsets().top - getInsets().bottom;

        contentPane = new JPanel() {
            public void paintComponent( Graphics g ) {            //(D)
                super.paintComponent( g );
                if ( finishedLoading && newFrameAvailable ) {
                    scrollableImage = 
                         new JScrollPane( 
                             new JLabel( 
                                 images[ frameIndex - 1 ],        //(E)
                                         JLabel.CENTER ) );
                    scrollableImage.setPreferredSize( 
                      new Dimension( 
                             displayWidth, displayHeight - 8 ) );
                }
                if ( scrollableImage != null ) {
                    contentPane.removeAll();
                    contentPane.add( scrollableImage );
                }
                contentPane.revalidate();

examples/corpus/SlideShowApplet.java  view on Meta::CPAN

        };
        contentPane.setBackground(Color.white);                   //(F)
        setContentPane(contentPane);

        statusLabel = new JLabel("Loading Images...", JLabel.CENTER);
        statusLabel.setForeground( Color.red );
        contentPane.add(statusLabel);

        timer = new Timer( pause, new ActionListener() {          //(G)
                public void actionPerformed( ActionEvent evt ) {
                    frameIndex++;                                 //(H)
                    if ( frameIndex == numImages )
                        frameIndex = 1;
                    newFrameAvailable = true;
                    contentPane.repaint();
                }
        });
        timer.setInitialDelay( 0 );
        timer.setCoalesce(false);        

        images = new ImageIcon[numImages];                        //(I)
        new Thread() {                                            //(J)
                public void run() {

examples/corpus/SlideShowApplet.java  view on Meta::CPAN

        return "Title: A SlideShow Applet\n";
    }
  
    public String[][] getParameterInfo() {                        //(P)
        String[][] info = {
          {"dir", 
           "String", 
           "the directory containing the images to loop"},
          {"pause", 
           "int", 
           "the time interval between successive frames"},
          {"numImages", 
           "int", 
           "the number of images to display; default is 10 " },
        };
        return info;
    }
}

examples/corpus_with_java_and_cpp/EventThreadDemo.java  view on Meta::CPAN

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;

class EventThreadDemo {

    public static void main( String[] args ) {

        JFrame frame = new JFrame( "Event Thread Demo" );

        frame.addWindowListener( new WindowAdapter() {
                public void windowClosing( WindowEvent e ) {
                    System.exit( 0 );
                }
        });

        JTextArea textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.getDocument().addDocumentListener(
                                 new MyDocumentListener());

examples/corpus_with_java_and_cpp/EventThreadDemo.java  view on Meta::CPAN

        areaScrollPane.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane.setPreferredSize(new Dimension(250, 250));
        areaScrollPane.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5,5,5,5)),
                areaScrollPane.getBorder()));
        
        frame.getContentPane().add( 
                       areaScrollPane, BorderLayout.CENTER );
        frame.pack();
        frame.setVisible( true );
        keepBusy( 500, "main" );                                  //(A)
    }

    static class MyDocumentListener implements DocumentListener {
        public void insertUpdate( final DocumentEvent e ) {
            String str = null;
            Document doc = e.getDocument();
            int lengthText = doc.getLength();
            try {
                str = doc.getText( lengthText - 1, 1 );

examples/corpus_with_java_and_cpp/EventThreadDemo2.java  view on Meta::CPAN

    }
}

////////////////////////  class LaunchFrame  /////////////////////////
class LaunchAFrame extends Thread {                               //(E)
    public LaunchAFrame() {}

    public void run() {                                           //(F)
        MyTools.printThreadInfo(                                  //(G)
                 "Just before creating Frame object:" );
        JFrame frame = new JFrame( "EventThreadsDemo 2" );        //(H)
        MyTools.printThreadInfo( 
                 "Just after creating Frame object:" );
        frame.addWindowListener( new WindowAdapter() {        
                public void windowClosing( WindowEvent e ) {
                    System.exit( 0 );
                }
        });
        JTextArea textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.getDocument().addDocumentListener(
                                new MyDocumentListener());
        MyTools.printThreadInfo(                                  //(I)

examples/corpus_with_java_and_cpp/EventThreadDemo2.java  view on Meta::CPAN


        areaScrollPane.setVerticalScrollBarPolicy(
                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        areaScrollPane.setPreferredSize(new Dimension(250, 250));
        areaScrollPane.setBorder(
            BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5,5,5,5)),
                areaScrollPane.getBorder()));
        frame.getContentPane().add( 
                       areaScrollPane, BorderLayout.CENTER );
        MyTools.printThreadInfo( "Just before calling pack:" );
        frame.pack();
        frame.setLocation( 300, 300 );
        frame.setVisible( true );
        MyTools.printThreadInfo("Just after calling setVisible:");//(K)     
    }
}

///////////////////////////  class MyTools  ///////////////////////////
class MyTools {                                                   //(L)
    public static void printThreadInfo( String s ) {              //(M)
        System.out.println( s );
//        Thread.currentThread().getThreadGroup().list();
//        System.out.println( 

examples/corpus_with_java_and_cpp/SlideShowApplet.java  view on Meta::CPAN



//SlideShowApplet.java

import javax.swing.*;
import java.awt.*;             //for Graphics, Color, Dimension, etc.
import java.awt.event.*;
import java.net.*;             //for URL needed for image loading

public class SlideShowApplet extends JApplet {                    //(B)
    int frameIndex = 0;        //current frame number
    String dir;                //directory relative to the codebase 
    Timer timer;               //timer for sequencing through images      
    int pause;                 //time interval between images
    int numImages;             //number of images to display
    int width;                 //width of the applet
    int height;                //height of the applet
    int displayWidth;
    int displayHeight;
    JComponent contentPane;    //the applet's content pane
    ImageIcon images[];        //the images

examples/corpus_with_java_and_cpp/SlideShowApplet.java  view on Meta::CPAN

        displayWidth = width - getInsets().left - getInsets().right;
        displayHeight = height - getInsets().top - getInsets().bottom;

        contentPane = new JPanel() {
            public void paintComponent( Graphics g ) {            //(D)
                super.paintComponent( g );
                if ( finishedLoading && newFrameAvailable ) {
                    scrollableImage = 
                         new JScrollPane( 
                             new JLabel( 
                                 images[ frameIndex - 1 ],        //(E)
                                         JLabel.CENTER ) );
                    scrollableImage.setPreferredSize( 
                      new Dimension( 
                             displayWidth, displayHeight - 8 ) );
                }
                if ( scrollableImage != null ) {
                    contentPane.removeAll();
                    contentPane.add( scrollableImage );
                }
                contentPane.revalidate();

examples/corpus_with_java_and_cpp/SlideShowApplet.java  view on Meta::CPAN

        };
        contentPane.setBackground(Color.white);                   //(F)
        setContentPane(contentPane);

        statusLabel = new JLabel("Loading Images...", JLabel.CENTER);
        statusLabel.setForeground( Color.red );
        contentPane.add(statusLabel);

        timer = new Timer( pause, new ActionListener() {          //(G)
                public void actionPerformed( ActionEvent evt ) {
                    frameIndex++;                                 //(H)
                    if ( frameIndex == numImages )
                        frameIndex = 1;
                    newFrameAvailable = true;
                    contentPane.repaint();
                }
        });
        timer.setInitialDelay( 0 );
        timer.setCoalesce(false);        

        images = new ImageIcon[numImages];                        //(I)
        new Thread() {                                            //(J)
                public void run() {

examples/corpus_with_java_and_cpp/SlideShowApplet.java  view on Meta::CPAN

        return "Title: A SlideShow Applet\n";
    }
  
    public String[][] getParameterInfo() {                        //(P)
        String[][] info = {
          {"dir", 
           "String", 
           "the directory containing the images to loop"},
          {"pause", 
           "int", 
           "the time interval between successive frames"},
          {"numImages", 
           "int", 
           "the number of images to display; default is 10 " },
        };
        return info;
    }
}

examples/corpus_with_java_and_cpp/WindowWithMenu.cc  view on Meta::CPAN

    QObject::connect( colormenu,
                      SIGNAL( activated( int ) ),
                      this,
                      SLOT( selectColor( int ) ) );


    menubar = new QMenuBar( this );
    menubar->insertItem( "&File", filemenu );
    menubar->insertItem( "Color", colormenu );

    QRect rect = menubar->frameGeometry();
    int h = rect.height();

    textarea = new QMultiLineEdit( this );
    textarea->setGeometry( 0, h, 300, 350 );
    textarea->setReadOnly( TRUE );
}


WindowWithMenu::~WindowWithMenu() { }



( run in 3.101 seconds using v1.01-cache-2.11-cpan-df04353d9ac )