Multiple use of DataRenderers

Hi all,

We had this a few months ago but now I ran in new troubles. I have
designed a class called DisplayData that holds everything related to a
Data object similar to SSCellData. One difference to SSCellData is that
you can assign a special DataRenderer to your DisplayData such as a
DirectManipulationRenderer. Then I have a subroutine that adds these
DisplayDatas to my DisplayImpl. The following is a code snippet of this
routine:

for (int i = 0 ; i < dataArray.length ; i++) {
  if (dataArray[i].getDataRenderer() == null) {
    if (dataArray[i].getConstantMaps() == null) {
      display.addReference(dataArray[i].getReference());
    } else {
      display.addReference(dataArray[i].getReference(),
dataArray[i].getConstantMaps());
    }
  } else {
    DataRenderer renderer
(DataRenderer)dataArray[i].getDataRenderer().getClass().newInstance();
    if (dataArray[i].getConstantMaps() == null) {
      display.addReferences(renderer, dataArray[i].getReference());
    } else {
      display.addReferences(renderer, dataArray[i].getReference(),
                            dataArray[i].getConstantMaps());
    }
  }
}

That works fine for all kinds of DataRenderers that need no arguments in
their constructor. But now I have to use a RubberBandBoxRendererJ3D
which needs at least two RealTypes as arguments. I could catch this by
asking if renderer is a RubberBandBoxRendererJ3D and then constructing
the new Renderer directly. But that would be a bad workaround because I
want to support all possible DataRenderers, even others without default
constructors. And it would be bad style to catch all possible
DataRenderers.

Are there any ideas for better workarounds? What about implementing a
copy constructor in the DataRenderers or a clone()-method?

Thanks a lot, Mathias


------------------------------------------------------------
Mathias Stümpert
email: mathias@xxxxxxxxxxxx
homepage: www.stuempert.de