_Visual Development Tools for Java_
by Steve V. Yalovitser
Listing One
// drdobbs.java -
// Version - 1.0
// zpb_begin Revisions
// zpb_end
import java.awt.*;
import java.util.*;
import java.applet.Applet;
import LogFontLayout; // Fixed position layout based on font size
// zpb_begin UserImports
// zpb_end
class SampleGenCodePane1 extends Canvas {
private static Applet applet;
// zpb_begin SampleGenCodePane1UserVars
// zpb_end
public SampleGenCodePane1(Applet app) {
applet = app;
// zpb_begin SampleGenCodePane1Constructor
// zpb_end
}
public void paint(Graphics g) {
Dimension d = size();
g.drawRect(0,0,d.width-1,d.height-1); // border
// zpb_begin SampleGenCodePane1Paint
// zpb_end
}
// zpb_begin SampleGenCodePane1UserMethods
// zpb_end
}
public
class drdobbs extends Applet {
private static Applet applet;
Label pStatic1;
Button pButton1;
Checkbox pRadioButton1;
CheckboxGroup pRadioButton1Group;
SampleGenCodePane1 pPane1;
// Initial size in logical units
Dimension initialSize = new Dimension(291, 172);
// zpb_begin SampleGenCodeUserVars
// zpb_end
public
void init() {
applet = this;
// zpb_begin AppletInit
// zpb_end
setBackground(Color.lightGray);
setFont(new Font("Helvetica", Font.PLAIN, 12));
LogFontLayout lfLayout = new LogFontLayout(this);
setLayout(lfLayout);
pButton1 = new Button("Button");
add("32 19 66 48", pButton1);
pStatic1 = new Label("Text");
add("133 20 22 42", pStatic1);
pRadioButton1Group = new CheckboxGroup();
pRadioButton1 = new Checkbox("Radio", pRadioButton1Group, false);
add("207 22 35 24", pRadioButton1);
pPane1 = new SampleGenCodePane1(applet);
add("74 83 79 50", pPane1);
// zpb_begin SampleGenCodeConstructor_2
// zpb_end
// Size in logical units
resize(getLayout().preferredLayoutSize(this));
// zpb_begin SampleGenCodeConstructor_3
// zpb_end
}
public Dimension minimumSize() {
// zpb_begin SampleGenCodeMinimumSize
// zpb_end
LayoutManager layoutMgr = getLayout();
if (layoutMgr instanceof LogFontLayout) {
// Convert from logical units to absolute coordinates
int w = initialSize.width;
int h = initialSize.height;
LogFontLayout layout = (LogFontLayout)layoutMgr;
return new Dimension(layout.duX(w), layout.duY(h));
}
return new Dimension(initialSize);
}
public boolean handleEvent(Event e) {
// zpb_begin SampleGenCodeHandleEvent
// zpb_end
return super.handleEvent(e);
}
public Frame getFrame(Container c) {
// zpb_begin AppletGetFrame
// zpb_end
if (c instanceof Frame || c == null)
return((Frame)c);
else
return(getFrame(c.getParent()));
}
public boolean action(Event evt, Object obj) {
if (evt.target == pButton1) {
// zpb_begin SampleGenCodeButton1Clicked
// zpb_end
}
// zpb_begin SampleGenCodeAction
// zpb_end
return true;
}
// zpb_begin SampleGenCodeAppletUserMethods
// zpb_end
}
// zpb_begin UserClasses
// zpb_end
Listing Two
/*
This class is a basic extension of the Applet class. It would generally be
used as the main class with a Java browser or the AppletViewer. But an instance
can be added to a subclass of Container. To use this applet with a browser or
the AppletViewer, create an html file with the following code:
SampleGenCode window
You can add controls to Simple with Cafe Studio.
(Menus can be added only to subclasses of Frame.)
*/
import java.awt.*;
public class SampleGenCode extends java.applet.Applet {
public void init() {
//{{INIT_CONTROLS
setLayout(null);
addNotify();
resize(insets().left + insets().right + 380, insets().top + insets().bottom + 281);
panel1=new Panel();
panel1.setLayout(null);
add(panel1);
panel1.reshape(insets().left + 49,insets().top + 128,203,75);
group1= new CheckboxGroup();
button1=new Button("Button");
add(button1);
button1.reshape(insets().left + 14,insets().top + 15,88,26);
label1=new Label("Label");
add(label1);
label1.reshape(insets().left + 126,insets().top + 15,70,105);
check1=new Checkbox("Radio button",group1, false);
add(check1);
check1.reshape(insets().left + 231,insets().top + 60,105,38);
check2=new Checkbox("Radio button",group1, false);
panel1.add(check2);
check2.reshape(42,30,105,18);
//}}
super.init();
}
public boolean handleEvent(Event event) {
return super.handleEvent(event);
}
//{{DECLARE_CONTROLS
Panel panel1;
CheckboxGroup group1;
Button button1;
Label label1;
Checkbox check1;
Checkbox check2;
//}}
}
Listing Three
import java.util.Vector;
import java.applet.Applet;
import java.awt.*;
import java.util.Hashtable;
import opusmeta.*;
import opusjava.*;
/******************************************************************************\
** **
** (C) Copyright 1996 by Autodesk, Inc. **
** **
** The information contained herein is confidential, proprietary **
** to Autodesk, Inc., and considered a trade secret as defined **
** in section 499C of the penal code of the State of California. **
** Use of this information by anyone other than authorized **
** employees of Autodesk, Inc. is granted only under a written **
** non-disclosure agreement, expressly prescribing the scope **
** and manner of such use. **
** **
\******************************************************************************/
/******************************************************************************\
** **
** This Java source file contains machine generated code which **
** will instantiate a HyperWire object network in Javaese. Because **
** the code is generated procedurally within HyperWire, it might appear **
** somewhat odd (repetitive, cryptic, etc.). **
\******************************************************************************/
final public class Hyperwire extends OpusApplet
{
Hashtable plugInMetaData = new Hashtable();
/******************************************************************************\
** **
** The following are the resetting methods. There is one method **
** for each module instance. The method is called when the **
** module is initialized and whenever the module needs to be **
** reset. These are NOT public methods. To reset a module **
** from the plug-in, or wherever, call the public **
** resetModule( Nodule aModule ) method with the module **
** you want to reset. **
** **
\******************************************************************************/
private final void resetModule0( Nodule aModule )
{
AppletBundle ab = ( AppletBundle ) aModule.getBundle();
OpusPlugInProperties ap = ( OpusPlugInProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 3 );
ab.setAttributesChanged( false );
ab.setIsClickable( false );
ab.setIsEnabled( true );
ab.setMouseNotify( true );
ab.setIsVisible( true );
ab.setRect( ( new Rectangle( 0, 0, 640, 480 ) ) );
ab.setRepaintWhenOff( true );
ab.setRepaintWhenOn( true );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setConstrainChildren( true );
ab.setBackdrop( new Backdrop( ( new Color ( 255, 255, 255 ) ) ) );
ab.setAppletInfo( "Another fine Opus generated applet.\\nGenerated on 04/25/96 at 04:19:13 PM\\nTo supply your own message here, edit the applet comment." );
{
String pInfoInitializer[][] =
{
};
ab.setParameterInfo( pInfoInitializer );
}
}
private final void resetModule1( Nodule aModule )
{
VisualBundle ab = ( VisualBundle ) aModule.getBundle();
OpusPlugInProperties ap = ( OpusPlugInProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
BmpButtonPlugIn aPlugIn = ( BmpButtonPlugIn ) aModule.getPlugIn();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setRect( ( new Rectangle( 78, 124, 59, 49 ) ) );
ab.setIsClickable( true );
ab.setIsDragOnTop( false );
ab.setRepaintWhenOn( true );
ab.setRepaintWhenOff( true );
ab.setResetWhenOn( false );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setIsMoveable( false );
ab.setIsSelectable( false );
ab.setIsVisible( true );
aPlugIn.setUpImageRef( ( new ImageReference( "3sync1.JPG", null, true, false, true, new Point ( 59,49 ) ) ) );
aPlugIn.setDownImageRef( ( new ImageReference( "", null, true, false, true, new Point ( 0,0 ) ) ) );
}
private final void resetModule2( Nodule aModule )
{
VisualBundle ab = ( VisualBundle ) aModule.getBundle();
LabelProperties ap = ( LabelProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setRect( ( new Rectangle( 229, 78, 100, 139 ) ) );
ab.setIsClickable( true );
ab.setIsDragOnTop( false );
ab.setRepaintWhenOn( true );
ab.setRepaintWhenOff( true );
ab.setResetWhenOn( false );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setIsMoveable( false );
ab.setIsSelectable( false );
ab.setIsVisible( true );
ap.setString( "Text" );
ap.setForeColor( ( new Color ( 0, 0, 0 ) ) );
ap.setBackColor( ( new Color ( 255, 255, 255 ) ) );
ap.setFont( new Font( "MS Sans Serif", 0, 11 ) );
ap.setHorizontalAlign( 1 );
ap.setTransparent( true );
ap.setVerticalAlign( 4 );
ap.setXMargin( 6 );
ap.setYMargin( 6 );
}
private final void resetModule3( Nodule aModule )
{
VisualBundle ab = ( VisualBundle ) aModule.getBundle();
OpusPlugInProperties ap = ( OpusPlugInProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
BmpButtonPlugIn aPlugIn = ( BmpButtonPlugIn ) aModule.getPlugIn();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setRect( ( new Rectangle( 448, 111, 59, 49 ) ) );
ab.setIsClickable( true );
ab.setIsDragOnTop( false );
ab.setRepaintWhenOn( true );
ab.setRepaintWhenOff( true );
ab.setResetWhenOn( false );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setIsMoveable( false );
ab.setIsSelectable( false );
ab.setIsVisible( true );
aPlugIn.setUpImageRef( ( new ImageReference( "3sync1.JPG", null, true, false, true, new Point ( 59,49 ) ) ) );
aPlugIn.setDownImageRef( ( new ImageReference( "", null, true, false, true, new Point ( 0,0 ) ) ) );
}
private final void resetModule4( Nodule aModule )
{
VisualContainerBundle ab = ( VisualContainerBundle ) aModule.getBundle();
VisualContainerProperties ap = ( VisualContainerProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setIsClickable( false );
ab.setIsEnabled( true );
ab.setMouseNotify( true );
ab.setIsVisible( true );
ab.setRect( ( new Rectangle( 146, 213, 200, 217 ) ) );
ab.setRepaintWhenOff( true );
ab.setRepaintWhenOn( true );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setConstrainChildren( true );
ab.setBackdrop( new Backdrop( ( new Color ( 255, 255, 255 ) ) ) );
ab.setIsMoveable( false );
}
private final void resetModule5( Nodule aModule )
{
VisualBundle ab = ( VisualBundle ) aModule.getBundle();
OpusPlugInProperties ap = ( OpusPlugInProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
BmpButtonPlugIn aPlugIn = ( BmpButtonPlugIn ) aModule.getPlugIn();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setRect( ( new Rectangle( 42, 0, 59, 49 ) ) );
ab.setIsClickable( true );
ab.setIsDragOnTop( false );
ab.setRepaintWhenOn( true );
ab.setRepaintWhenOff( true );
ab.setResetWhenOn( false );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setIsMoveable( false );
ab.setIsSelectable( false );
ab.setIsVisible( true );
aPlugIn.setUpImageRef( ( new ImageReference( "3sync1.JPG", null, true, false, true, new Point ( 59,49 ) ) ) );
aPlugIn.setDownImageRef( ( new ImageReference( "", null, true, false, true, new Point ( 0,0 ) ) ) );
}
private final void resetModule6( Nodule aModule )
{
VisualContainerBundle ab = ( VisualContainerBundle ) aModule.getBundle();
VisualContainerProperties ap = ( VisualContainerProperties ) ( ( OpusBasicPlugIn ) aModule.getPlugIn() ).getProperties();
ab.setUserData( OpusString.from( "nil" ) );
ab.setBaseFlags( 2 );
ab.setAttributesChanged( false );
ab.setIsClickable( false );
ab.setIsEnabled( true );
ab.setMouseNotify( true );
ab.setIsVisible( true );
ab.setRect( ( new Rectangle( 0, 17, 200, 200 ) ) );
ab.setRepaintWhenOff( true );
ab.setRepaintWhenOn( true );
ab.setReferencePoint( new ReferencePoint ( 8 ) );
ab.setConstrainChildren( true );
ab.setBackdrop( new Backdrop( ( new Color ( 255, 255, 255 ) ) ) );
ab.setIsMoveable( false );
}
/******************************************************************************\
** **
** Method: public void resetModule( Nodule aModule ) **
** Purpose: **
** Resets aModule back to its initial state. **
** **
\******************************************************************************/
public void resetModule( Nodule aModule )
{
switch ( aModule.getID() )
{
case 0:
resetModule0( aModule );
break;
case 1:
resetModule1( aModule );
break;
case 2:
resetModule2( aModule );
break;
case 3:
resetModule3( aModule );
break;
case 4:
resetModule4( aModule );
break;
case 5:
resetModule5( aModule );
break;
case 6:
resetModule6( aModule );
break;
default:
break;
}
}
/******************************************************************************\
** **
** Method: void instantiateModules() **
** Purpose: **
** Instantiates the nodules, run-reps and models and links up **
** the module hierarchy. **
\******************************************************************************/
protected void instantiateModules()
{
Nodule aNodule;
RunRepresentation aRunRep;
Nodule rootAppletModule;
moduleEnumeration = new Nodule[7];
nModules = 0;
/******************************************************************************\
** **
** Step: 1 **
** Task: Instantiate the modules. Builds **
** a mapping array which maps module IDs (ints) to their **
** corresponding module references. **
** **
\******************************************************************************/
// Get the appropriate meta data for module of type: Title Module
if( plugInMetaData.get( "AppletModuleMetaData" ) == null)
{ plugInMetaData.put( "AppletModuleMetaData", (new AppletModuleMetaData() ) ); }
// Instantiate Module of Type: Title Module PathName: /Title Module
newModule( ( new AppletPlugIn() ), "Title Module", (PlugInMetaData) plugInMetaData.get( "AppletModuleMetaData") );
// Get the appropriate meta data for module of type: Button
if( plugInMetaData.get( "BmpButtonMetaData" ) == null)
{ plugInMetaData.put( "BmpButtonMetaData", (new BmpButtonMetaData() ) ); }
// Instantiate Module of Type: Button PathName: /Title Module/Button
newModule( ( new BmpButtonPlugIn() ), "Button", (PlugInMetaData) plugInMetaData.get( "BmpButtonMetaData") );
// Get the appropriate meta data for module of type: Label
if( plugInMetaData.get( "LabelMetaData" ) == null)
{ plugInMetaData.put( "LabelMetaData", (new LabelMetaData() ) ); }
// Instantiate Module of Type: Label PathName: /Title Module/Label
newModule( ( new LabelPlugIn() ), "Label", (PlugInMetaData) plugInMetaData.get( "LabelMetaData") );
// Get the appropriate meta data for module of type: Button
if( plugInMetaData.get( "BmpButtonMetaData" ) == null)
{ plugInMetaData.put( "BmpButtonMetaData", (new BmpButtonMetaData() ) ); }
// Instantiate Module of Type: Button PathName: /Title Module/Button1
newModule( ( new BmpButtonPlugIn() ), "Button1", (PlugInMetaData) plugInMetaData.get( "BmpButtonMetaData") );
// Get the appropriate meta data for module of type: Visual Container
if( plugInMetaData.get( "VisualContainerMetaData" ) == null)
{ plugInMetaData.put( "VisualContainerMetaData", (new VisualContainerMetaData() ) ); }
// Instantiate Module of Type: Visual Container PathName: /Title Module/Visual Container1
newModule( ( new VisualContainerPlugIn() ), "Visual Container1", (PlugInMetaData) plugInMetaData.get( "VisualContainerMetaData") );
// Get the appropriate meta data for module of type: Button
if( plugInMetaData.get( "BmpButtonMetaData" ) == null)
{ plugInMetaData.put( "BmpButtonMetaData", (new BmpButtonMetaData() ) ); }
// Instantiate Module of Type: Button PathName: /Title Module/Visual Container1/Button2
newModule( ( new BmpButtonPlugIn() ), "Button2", (PlugInMetaData) plugInMetaData.get( "BmpButtonMetaData") );
// Get the appropriate meta data for module of type: Visual Container
if( plugInMetaData.get( "VisualContainerMetaData" ) == null)
{ plugInMetaData.put( "VisualContainerMetaData", (new VisualContainerMetaData() ) ); }
// Instantiate Module of Type: Visual Container PathName: /Title Module/Visual Container1/Visual Container
newModule( ( new VisualContainerPlugIn() ), "Visual Container", (PlugInMetaData) plugInMetaData.get( "VisualContainerMetaData") );
/******************************************************************************\
** **
** Step: 2 **
** Task: Setup links from each parent container to its submodules. **
** **
\******************************************************************************/
aNodule = fromID(0);
linkChildModule( aNodule, 1 );
linkChildModule( aNodule, 2 );
linkChildModule( aNodule, 3 );
linkChildModule( aNodule, 4 );
aNodule = fromID(4);
linkChildModule( aNodule, 5 );
linkChildModule( aNodule, 6 );
aNodule = fromID(6);
/******************************************************************************\
** **
** Step: 3 **
** Task: Call a little recursive method which fixes up all the module **
** backpointers in the hierarchy. **
** **
\******************************************************************************/
mRootModule = fromID( 0 );
mRootModule.setOwner( null );
fixupModuleBackpointers( mRootModule );
}
/******************************************************************************\
** **
** Method: void instantiateWiring() **
** Purpose: **
** Instantiates the wiring network. **
\******************************************************************************/
protected void instantiateWiring()
{
Nodule senderModule;
Nodule receiverModule;
Interface senderInputInterface;
Interface senderOutputInterface;
Interface receiverInterface;
UserMessageTableEntry mte;
WireMessage aWire[] = new WireMessage[32];
portEnumeration = new UserMessageTableEntry[0];
/******************************************************************************\
** **
** Step: 1 **
** Task: Instantiate the interface ports for the modules. **
\******************************************************************************/
/******************************************************************************\
** **
** Step: 2 **
** Task: Instantiate the wires. **
\******************************************************************************/
}
}