~ubuntu-branches/ubuntu/precise/jcsp/precise

« back to all changes in this revision

Viewing changes to src/jcsp-demos/picasso/PicassoMain.java

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-06-20 18:12:26 UTC
  • Revision ID: james.westby@ubuntu.com-20100620181226-8yg8d9rjjjiuy7oz
Tags: upstream-1.1-rc4
ImportĀ upstreamĀ versionĀ 1.1-rc4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
    //////////////////////////////////////////////////////////////////////
 
2
    //                                                                  //
 
3
    //  JCSP ("CSP for Java") Libraries                                 //
 
4
    //  Copyright (C) 1996-2008 Peter Welch and Paul Austin.            //
 
5
    //                2001-2004 Quickstone Technologies Limited.        //
 
6
    //                                                                  //
 
7
    //  This library is free software; you can redistribute it and/or   //
 
8
    //  modify it under the terms of the GNU Lesser General Public      //
 
9
    //  License as published by the Free Software Foundation; either    //
 
10
    //  version 2.1 of the License, or (at your option) any later       //
 
11
    //  version.                                                        //
 
12
    //                                                                  //
 
13
    //  This library is distributed in the hope that it will be         //
 
14
    //  useful, but WITHOUT ANY WARRANTY; without even the implied      //
 
15
    //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR         //
 
16
    //  PURPOSE. See the GNU Lesser General Public License for more     //
 
17
    //  details.                                                        //
 
18
    //                                                                  //
 
19
    //  You should have received a copy of the GNU Lesser General       //
 
20
    //  Public License along with this library; if not, write to the    //
 
21
    //  Free Software Foundation, Inc., 59 Temple Place, Suite 330,     //
 
22
    //  Boston, MA 02111-1307, USA.                                     //
 
23
    //                                                                  //
 
24
    //  Author contact: P.H.Welch@kent.ac.uk                             //
 
25
    //                                                                  //
 
26
    //                                                                  //
 
27
    //////////////////////////////////////////////////////////////////////
 
28
 
 
29
 
 
30
import org.jcsp.lang.*;
 
31
import org.jcsp.awt.*;
 
32
import org.jcsp.demos.util.Ask;
 
33
 
 
34
/**
 
35
 * @author P.H. Welch
 
36
 */
 
37
public class PicassoMain extends ActiveApplet {
 
38
 
 
39
  public static final String TITLE = "Picasso";
 
40
  public static final String DESCR =
 
41
        "Demonstrates the handling of AWT mouse events by a basic drawing process.";
 
42
 
 
43
  public static final int minWidth = 100;
 
44
  public static final int maxWidth = 1024;
 
45
 
 
46
  public static final int maxHeight = 768;
 
47
  public static final int minHeight = 100;
 
48
 
 
49
  public void init () {
 
50
    setProcess (new PicassoNetwork (this));
 
51
  }
 
52
 
 
53
  public static void main (String argv[]) {
 
54
 
 
55
    Ask.app (TITLE, DESCR);
 
56
        Ask.addPrompt ("width", minWidth, maxWidth, 640);
 
57
        Ask.addPrompt ("height", minHeight, maxHeight, 480);
 
58
        Ask.show ();
 
59
    final int width = Ask.readInt ("width");
 
60
    final int height = Ask.readInt ("height");
 
61
    Ask.blank ();
 
62
 
 
63
    final ActiveClosingFrame activeClosingframe = new ActiveClosingFrame ("Picasso");
 
64
    final ActiveFrame activeFrame = activeClosingframe.getActiveFrame ();
 
65
    activeFrame.setSize (width, height);
 
66
 
 
67
    final PicassoNetwork picassoNetwork = new PicassoNetwork (activeFrame);
 
68
 
 
69
    activeFrame.pack ();
 
70
    activeFrame.setLocation ((maxWidth - width)/2, (maxHeight - height)/2);
 
71
    activeFrame.setVisible (true);
 
72
    activeFrame.toFront ();
 
73
 
 
74
    new Parallel (
 
75
      new CSProcess[] {
 
76
        activeClosingframe,
 
77
        picassoNetwork
 
78
      }
 
79
    ).run ();
 
80
 
 
81
  }
 
82
 
 
83
}