I was finally able to figure out why I was getting a
NullPointerException in my pluggable rendering code. It is becuase
OpenJUMP is attempting to render Java String objects. (At least that
is what it looks like to me.)
My code returns a NullPointerException when it encounters one of these
Strings because I didn't design it to return a Renderer objecct for
Strings.
Here is how I found out what was happening. I added some logging
statements using log4j in the LayerViewPanel.repaint() method. I knew
that this was the source of the NullPointerException. I also suspected
that OpenJUMP was passing me something other that a Layer or WMSLayer
to render. So I modified the LayerViewPanel.repaint() method to loop
through the List of ContentIDs, or objects to be rendered. I think
printed the class name of each object in the List. After I found out
that the objects causing me problems were Strings, I modified the
logging statements in the repaint() method to also print out the value
of the Strings.
The Strings that are present in the List of objects to be rendered
when OpenJUMP first starts have the following values:
SELECTION_BACKGROUND
SELECTED_FEATURES
SELECTED_LINESTRINGS
SELECTED_PARTS
GRID
SCALE_SHOW
SCALE_BAR
Isn't this odd? Those Strings almost look like Constant values. I
wonder where in the world they are coming from?
I've attached a text file that contains the logging statements I put
into the modified LayerViewPanel.repaint() method. I have also
attached the log file that contains the text from the logging
statements.
I can modify my pluggable rendering system to ignore String objects,
but I'd really like to know how they end up in the ContentIDs List to
begin with. Thank you in advance for any suggestions or insight.
The Sunburned Surveyor
P.S. - I just found a new friend. His name is log4j. :]
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The String has a value of: GRID
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The String has a value of: SELECTION_BACKGROUND
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The String has a value of: SELECTED_FEATURES
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The String has a value of: SELECTED_LINESTRINGS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The String has a value of: SELECTED_PARTS
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The String has a value of: SCALE_SHOW
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The class we couldn't find a renderer for was: java.lang.String
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
DEBUG - The String has a value of: SCALE_BAR
public void repaint()
{
if(renderingManager == null)
{
superRepaint();
return;
}
else
{
List contentIDs = renderingManager.contentIDs();
Log4JSetUp setUpLogger = new Log4JSetUp();
setUpLogger.setLogFile("C://Temp/logs/debug_output.txt");
setUpLogger.setUpLog4J(com.vividsolutions.jump.workbench.ui.LayerViewPanel.class);
Logger logger = setUpLogger.getLogger();
Iterator loopThrough = contentIDs.iterator();
while(loopThrough.hasNext())
{
Object contentID = loopThrough.next();
Class contentIDClass = contentID.getClass();
String className = contentIDClass.getName();
logger.debug("The class we couldn't find a
renderer for was: " + className);
String StringToPrint = contentID.toString();
logger.debug("The String has a value of: " +
StringToPrint);
}
if (contentIDs.isEmpty())
{
/* If nothing needs to be rendered we just want
* to call the repaint() method of the JPanel.
If we
* try to call the LayerViewPanels custom
rendering code
* when there is nothing to render we'll get a
NullPointerException. This
* change was made to support pluggable
rendering.
* [2007-05-21 The Sunburned Surveyor]
*/
superRepaint();
return;
}
else
{
renderingManager.renderAll();
}
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel