//***************************************************************************
// Application: Villanova Cat Cave Conference Center
// File: toolKit.java
// Module: toolKit
// Version: 1.0
// Written by: Mark Juliano and Sharon Morris and
// Dharmendra Katkuri and Graham Mehl
// Villanova Master of Science Candidate
// Independent Study project
// Date: 3/31/96
//
// Purpose: The purpose of this file is to create, display and
// respond to the actions of an user regarding a tool kit.
// The tool kit is composed of multiple images to make it
// appear as if a button was being pressed when the user
// clicks on it. Also the challege of this window was to
// place images on the button to make it more appealling
// then simple text.
//
//***************************************************************************
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import buttbar;
public class toolKit extends Applet
{
buttbar m_pBar = null;
butt m_pButton = null;
butt m_pButton2= null;
URL m_url;
Image m_ups[], m_downs[], m_I1, m_I2, m_I3, m_manu, m_mand;
int m_tot;
Label m_lbl;
Button m_hidebar, m_showbar, m_disbutton;
AudioClip m_sound;
// *************************************************************
CardWindow card;
MakeButtonPanel mb;
zClientDef clientDef;
private int mode; // Indicates current button selected -> used
// by whiteboard
private Color color; // Indicates current color selected -> used
// by whiteboard
Choice color_button = new Choice(); // Creating the
// the color button
// seperately so can
// Set the color of
// of the color button
public int contVar = 0;
Vector up_images;
Vector down_images;
public void setCardWindow( CardWindow c )
{
card = c;
}
public void setMakeButtonPanel( MakeButtonPanel m )
{
mb = m;
}
// *************************************************************
public toolKit( zClientDef commHandle , Vector up_img, Vector down_img)
{
clientDef = commHandle;
mode = -1;
color_button.setBackground( getColor() ); // Set the color of
setColor(Color.black);
up_images = (Vector) up_img;
down_images = (Vector) down_img;
this.init();
}
public void init()
{
int i;
m_tot = 12;
m_ups = new Image [m_tot];
m_downs = new Image [m_tot];
Image imm;
up_images.copyInto(m_ups);
down_images.copyInto(m_downs);
try
{
m_url = new URL("http://renoir.vill.edu/csc/dkatkuri/ind/scr/jav1/jav2/butt.html");
}
catch( MalformedURLException e )
{
m_url = null;
}
addButtons();
m_pBar.resize(100,350);
m_pBar.setResizable(false);
repaint();
}
public void stop()
{
if (m_pBar != null)
m_pBar.hide();
}
public void Show()
{
m_pBar.show();
}
public void Hide()
{
m_pBar.hide();
}
public void Dispose()
{
m_pBar.dispose();
}
public void addButtons()
{
color_button.addItem("Black");
color_button.addItem("Blue");
color_button.addItem("Red");
color_button.addItem("Yellow");
color_button.addItem("Green");
color_button.addItem("Cyan");
color_button.addItem("Orange");
color_button.addItem("Pink");
color_button.addItem("Gray");
color_button.addItem("Magenta");
color_button.select("Black");
color_button.resize( 60, 45 );
// use the image arrays to create a buttbar object
add(m_pBar = new buttbar(m_ups, m_downs, null, m_tot, false,
color_button));
}
// *************************************************************
/*
* Added show and hide functions to toolkit.java
*/
public void showToolkit()
{
this.Show();
}
public void hideToolkit()
{
this.Hide();
}
/*
* set the mode for the toolkit, this will probably be
* called when you select a button
*/
public void setMode( int m )
{
mode = m;
}
/*
* the two functions below, getMode & getColor allow the whiteboard to
* query what the current toolkit attributes are
*/
public int getMode()
{
return( mode );
}
/*
* set the color for the toolkit, this will probably be
* called when you change the active color
*/
public void setColor( Color c )
{
color = c;
}
public void setColor( String c )
{
if( c == "Blue" )
{
color = Color.blue;
}
if( c == "Red" )
{
color = Color.red;
}
if( c == "Black" )
{
color = Color.black;
}
if( c == "Yellow" )
{
color = Color.yellow;
}
if( c == "Cyan" )
{
color = Color.cyan;
}
if( c == "Magenta" )
{
color = Color.magenta;
}
if( c == "Green" )
{
color = Color.green;
}
if( c == "Gray" )
{
color = Color.gray;
}
if( c == "Orange" )
{
color = Color.orange;
}
if( c == "Pink" )
{
color = Color.pink;
}
}
/*
* gets the color for the toolkit, this will probably be
* called when you change the active color
*/
public Color getColor()
{
return( color );
}
// ***********************************************************
public boolean action(Event e, Object arg)
{
String cc = (String)arg;
int dd = color_button.getSelectedIndex();
String newColor = color_button.getItem(dd);
setColor(cc);
// Display the Active Color
color_button.setBackground( getColor() );
return true;
}
public boolean mouseDown(Event evt, int x, int y)
{
StringBuffer SendMe = new StringBuffer();
while (true)
{
if (evt.target == (Component)m_pButton)
{
break;
}
else
if (evt.target == (Component)m_pButton2)
{
if (m_url != null)
getAppletContext().showDocument( m_url);
}
// handle messages from the buttbar object
// check m_button[..] components
for (int i = 0; i < m_tot; i++)
{
if (evt.target == (Component)m_pBar.m_button[i])
{
mode = i;
break;
}
}
switch(mode)
{
case 10: // clear
SendMe.append( "W" );
SendMe.append( card.returnpg() );
SendMe.append( ":" );
SendMe.append( "R" );
clientDef.zCommDispatch( "_PM_", SendMe.length(), SendMe.toString() );
/*
* clear this whiteBoard
*/
mb.zReceiveData( SendMe.toString() );
break;
case 11: //clear all
for( int pgCount = 0; pgCount != card.returntot(); pgCount++ )
{
SendMe = new StringBuffer();
SendMe.append( "W" );
SendMe.append( ( pgCount + 1 ) );
SendMe.append( ":" );
SendMe.append( "R" );
clientDef.zCommDispatch( "_PM_", SendMe.length(), SendMe.toString() );
/*
* clear this whiteBoard
*/
mb.zReceiveData( SendMe.toString() );
}
break;
case 8:
// for( int pgCount = 0; pgCount != card.returntot(); pgCount++ )
// {
SendMe.append( "W" );
// SendMe.append( ( pgCount + 1 ) );
SendMe.append( card.returnpg() );
SendMe.append( ":" );
SendMe.append( "U" );
clientDef.zCommDispatch( "_PM_", SendMe.length(), SendMe.toString() );
/*
* clear this whiteBoard
*/
mb.zReceiveData( SendMe.toString() );
// mode = 10;
// }
break;
case 5: //contline
contVar = 1;
break;
}
break;
}
return false;
}
// Handle Event by object
/* public boolean action(Event evt, Object obj)
{
// disable/enable button
if (evt.target == (Component)m_disbutton)
{
if (m_pButton.isEnabled())
{
m_disbutton.setLabel("Enable Duke");
m_pButton.disable();
}
else
{
m_disbutton.setLabel("Disable Duke");
m_pButton.enable();
}
}
return false;
}*/
}
Top of Paper |
Previous Page |
Next Page |
Bottom of Paper
Written By Graham L. Mehl
Last Modified on April 23, 1996
© Villanova University