ActionManager
contains an ActionListener which redirects the calls
to specialized functions of the form
public void/whatever something(ActionEvent e)
only one redirection per component!
tries to make a class from its name, possibly incomplete (without package prefix)
returns all found classes with the given name (several packages) if the flag is true
we use directly the focus event mask to manage the focus,
it is simple and efficient
we overrides all the constructors of Label to
provide a flexible component
returns the argument of an option:
null if the option was not found, "" if no argument, "...something"
if the argument is found
the option should be complete, for example: "-o" for the option -o
returns a list of possible classes for this package
we say "possible", that means that the classes are not
checked! The names are relative to the package
returns the definition of an option:
-option=something : getDefinition("-option") returns "something"
returns null if the option is not defined and "" if the definition
string is empty
-option = something ; -option= something ; -option =something are not recognized
the dimension taken by the rendered image and triangle ;
updateDim() is assumed to be called before ; has to be done
explicitely if one changes one icon ; implements TNodeRenderer
the dimension taken by the rendered image and triangle ;
updateDim() is assumed to be called before ; has to be done
explicitely if one changes one icon
get an icon by its resource name (without .icon extension)
return null if not found
the default name is resourceName.gif
where the '.' in the resourceName have been replaced by '_'
returns the interval where the source of the constructor/method can
be found ; arguments are the name(short) and the arguments(long)
not supported: type / comment / []...
the shared instance of this class ; shared since its
only purpose is to draw an image ; I adopt here a weak
programming model, namely the icons are assumed not to
be modified by a process while the instance is rendering
them, or updating the size information.
invalidate the node given in arguments
if one node is not valid, then all its parents
are not valid, so we do not need to propagate when we
find one !valid, thus the test in the loop
JavaFinder
a java source finder: works on the class path and
the property java.source.path which contains
path to java source like CLASSPATH
The property is given to the program via the command line
with the option -Djava.source.path=...
syntax of the class passed in argument:
class Data {
### all members should be declared public, otherwise they may not be read or written
static String name1; => name1 is the resource name and the default value
static String name2="default"; => here the default value is given
static Icon name3; => name3 is the resource name for an icon object
default is name3.gif
### String resources are defined as: resourceName.name=...
JTextAreaOutputStream
output stream JTextArea (from JStringOutputStream)
as JTextArea is slow, it could be nice to use this class
inside a BufferedOutputStream to enhance performance
easy solution:
return new Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource(iconPath+name));
but java crashes sometimes:
Uncaught error fetching image:
java.lang.NullPointerException
at java.net.URLConnection.guessContentTypeFromStream(URLConnection.java)
at sun.net.www.URLConnection.getContentType(URLConnection.java:126)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:98)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:259)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:151)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:127)
so we do the job in another way: load the data and create an image from the data
unused methods of listeners
I prefer to use this method instead of using the
"empty" listener provided by Sun, which we should
extend, imagine, you download two classes just for
a simple listener, and you have to pass arguments
to have access to what you want.
PackageFinder
finds only the packages, does not record the classes,
java is too weak for this, the virtual machine crashes
if we make a Class for every class
paint this component (node) ; basically paints a triangle if necessary (if
there is a content ; the cell is painted by the container function
paintComponents(..)
give the path of longName, with separator as separator,
replace '.' by '/' instead of File.separatorChar if the flag is set, and the path is then of the
form "" or "name/name/"
we want to do something for Enumeration, but the problem is that
when we use one , then we consume it and we can not use any more,
for this reason, we have this special function which produces one
copy and prints an Enumeration to the given PrintStream
the boolean tells whether to replace sub-enumeration objects by copies
or not, and thus to print them or not
Enumeration inside Vector or arrays are not printed!
constructor: the object to be wrapped
the object must not be null!
if it is null, a NullPointerException will
be raised one day, which is a good thing because
one is not supposed to sort null objects
TNode : Tree Node
I create my own tree component because Java copies the nodes
without telling me when, and it copies the content of the nodes
as well, so when my other components refer to these nodes, well,
they are not valid because they have been replaced by new ones!
Imagine the time I've lost to understand where the problem came
from, and then to implement my own tree!!!
This is my second version of tree: it is 100% swing free, only
pure java awt, which is much much faster than swing.
contructor : take the content ; if it is a component, it will display
itself, otherwise a label will be created with its toString()
the DefaultTNodeRenderer is used
real constructor : takes the content (object), the renderer
and a component to display the content ; the component should
be able to update itself when its background changes.
the icons themselves ; note that they are the same
in adavid.awt.ImageTNodeRenderer ; the difference is
that here we have Icon (which are ImageIcon in fact)
see ImageTNodeRenderer for comments on the weak programming
model
the icons themselves ; note that they are the same
in adavid.awt.ImageTNodeRenderer ; the difference is
that here we have Icon (which are ImageIcon in fact)
see ImageTNodeRenderer for comments on the weak programming
model
setup windoze related problems correction
I do not use the test on os, but on the file separator
because the os could be Windoze 95/98/NT and I do not care