KaAPI - K(C)ustomizable awt API
To provide Customization and Extendibility for a Java application during _RUNTIME_ with the features provides by the Java language only. The API should not have any native method implementations and hence should be binary compatible on all Java platforms.
KaAPI is a framework, primarily for creating UI applications in Java using the java.awt package that could be customizable and extendable by the user of the application by adding/replacing new UI components and preserving the original semantics of the application.
The framework also supports customization of any non-UI components. ( any Java class which is KaAPI enabled ,like sort algorithm )
Any java class which implements the KUIComponent interface can be added to the KaAPI aware application.
Any KUIComponent in a KaAPI aware application can be deleted. The side effect could be that the application might break if the deleted component is referenced by any other component. KUIComponents that are stand-alone can be deleted without breaking the application.
Any KUIComponent can be replaced with any other KUIComponent with some limitations
KUIComponents can be placed at different locations and also its dimension, color etc can be modified.
The following features are provided for the programmers, who develop KaAPI enabled components.
A KUIComponent can be shown/hidden, and this can be dynamically changed from with-in another KUIComponent. This would be useful to create all the KUIComponents and show/hide them programatically.
A KUIComponent can clone an existing KUIComponent dynamically. Cloned objects have the same behavior, but can have different view.(ex:- a cloned button can have a different Label)
Provides support for application enhancements and customization.
The look-n-feel of the application can be customized depending on the user needs.
Application prototypes can be generated faster by simply editing the format files and without changing sources. (next version would include a Visual format editor which would make prototyping even faster)
Since all information about the KUI components is kept in a text file(.format), the semantics of the application could be changed by a bad programmer/user.
Replacing a particular component (be it UI or non-UI) can only be done as follows :-
Note :- With JDK 1.1 any KUIComponent class can be replaced with any other KUIComponent class provided all the public method's signature (method_name,arguments) of the former and the latter are the same
This is responsible for placing and creation of the KUI ( KaAPI UI ) components. The Application needs to create an Object of this class.
This class is the interface between any KUI Component and its parent KFrame class.
This is used to validate any format file.
The interface definition.
All instances of KUI Component names are kept in a text file with .format extension. The format file should be passed to the KFrame() constructor.
The following code fragment shows how to create a KFrame object and initialize the application
package Apps ;
import java.lang.* ;
import java.io.* ;
import java.awt.* ;
import java.util.* ;
import KaAPI.* ;
/**
* KaAPI Framework Demo
*
* @version 1.1 19 Oct 1996
* @author shiva
**/
public class KaAPIdemo
{
public static void main( String[] args )
{
if ( args.length <= 0 ){
System.out.println("Usage : KaAPIdemo <filename>") ;
System.exit(0) ;
}
KFrame wf = null ;
try {
wf = new KFrame( args[0] ) ;
}
catch( IOException e ){
System.out.println(
args[0]+" is not found or the syntax is incorrect.") ;
System.out.println(
"Run KUICc on the format file if exists") ;
System.exit(0) ;
}
wf.setTitle("KaAPI Framework Demo") ;
wf.setBackground(Color.lightGray) ;
wf.showFrame() ;
}
}
The following file is a java.awt.Button class that is KaAPI enabled
package KaAPI.widgets ;
import java.io.* ;
import java.awt.* ;
import KaAPI.* ;
/**
* Button that is KaAPI framework aware
*
* @version 1.1 11 Aug 1996
* @author shiva
**/
public class KUICButton extends Button implements KUIComponent
{
private int _location ;
private int _visibility ;
protected String[] ArgsKuic ;
protected String[] KuicLinks ;
protected String VarName ;
protected KFrameAgent FrameAgent ;
public KUICButton()
{
super(KFrame.AGENT.getArguments(0)) ;
}
public int getUICLocation()
{
return _location ;
}
public int getUICVisibility()
{
return _visibility ;
}
public boolean setUICVisibility(int visFlag)
{
switch( visFlag ){
case KUIComponent.UIC_VISIBILITY_TOGGLE:
if ( _visibility == KUIComponent.UIC_VISIBILITY_SHOW )
_visibility = KUIComponent.UIC_VISIBILITY_HIDE ;
else
if ( _visibility == KUIComponent.UIC_VISIBILITY_HIDE )
_visibility = KUIComponent.UIC_VISIBILITY_SHOW ;
break ;
case KUIComponent.UIC_VISIBILITY_SHOW:
case KUIComponent.UIC_VISIBILITY_HIDE:
_visibility = visFlag ;
}
return true ; /* change in visibility accepted */
}
public void initUIC(String[] argsKaapi,String[] argsKuic,
String[] uicLinks,KFrameAgent frameAgent)
{
ArgsKuic = argsKuic ;
FrameAgent = frameAgent ;
VarName = FrameAgent.getVariableName((KUIComponent)this);
KuicLinks = uicLinks ;
_location = frameAgent.getLocation(argsKaapi) ;
_visibility = frameAgent.getVisibility(argsKaapi) ;
}
public void addUIC(KUIComponent kuic)
{
}
}