You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Chimera <ch...@ennersea.net> on 2004/06/05 04:20:32 UTC
Re: Need help/tutoring off-list
Is there anyone available/willing to help people anymore on this list?
This list has become dangerously quiet with the absence/busy-ness of
Thomas and a few others. :(
Chimera wrote:
> Would anyone on the list be willing to look through my code (multiple
> files) and help me where I am having errors? It should be a simple
> newbie error, easy for you guys to spot.
> This is the situation. I am building an app to learn from, and am
> combining Ivor Horton's Beginning Java 2 (1.4 Edition) and the SVG
> Example from the Batik website. My end goal is an open source
> wargame, just something I have always wanted to do, combined with the
> learning to program goal I have.
>
> The application has multiple classes.
> OpenWarSim main class
> AppMainFrame the actual application frame
> MapView class that loads an SVG file that works in the SVG
> viewer
> StatusBar bottom bar that gives feedback and data
> ( a few other supporting files )
>
> The OpenWarSim file is the main class that when launched, fires a
> splashscreen class (now commented out for speed) and the
> AppMainFrame. AppMainFrame consists of a menu bar (two things
> working: Game > Load Map, Game > Exit and Close) a JPanel and a
> Status Bar that gives feedback.
>
> Now, the StatusBar class works. I have successfully pumped the SVG
> listener events to give output to this bar. However, the process
> stops at addGVTTreeBuilderListener which is what started my problems.
> addGVTTreeRendererListener never fires. As a note, the Batik .jars
> are included fine, and when I build SVGTestExample.java (the Batik
> example from the site) in this same package as a standalone class, it
> builds fine. It was this that I used to troubleshoot any svg errors
> in my file. :)
>
> I suspect that this is a simple problem with how I have constructed
> things. Inside the JScrollPane in the AppMainFrame center, I am
> trying to create the JSVGCanvas.
>
> // Begin AppMainFrame class code...
>
> // TODO - This is where we are seemingly failing. The MapView
> JScrollPane is not
> // being created at all. JScrollPane
> panel = new JScrollPane();
> // Set up the main window data.
> panel.setPreferredSize(new java.awt.Dimension(mapWidth,
> mapHeight));
> // The main map, displaying elements, routes and objectives.
> panel.setToolTipText("Situation and Update Map");
> JSVGCanvas svgCanvas = new JSVGCanvas();
> panel.add(svgCanvas);
>
> // Add the windowTabbedPane to the MasterFrame, centered.
> getContentPane().add(panel, java.awt.BorderLayout.CENTER);
> MapView mapView = new MapView(mainApp, panel);
>
> // .... skip a lot of menu building code ...
>
> private void
> loadMapMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
> JFileChooser chooser = new JFileChooser(owsMapsDirectory);
> int choice = chooser.showOpenDialog(mapView);
> if (choice == JFileChooser.APPROVE_OPTION) {
> File file = chooser.getSelectedFile();
> try {
> svgCanvas.setURI(file.toURL().toString());
> } catch (IOException ex) {
> ex.printStackTrace();
> }
> }
> }
>
> // End AppMainFrame class code...
>
>
> // Begin MapView class code...
>
> public MapView(OpenWarSim mainApp, JScrollPane panel) {
> // Default constructor
> this.mainApp = mainApp;
> panel.setPreferredSize(new java.awt.Dimension(mapWidth,
> mapHeight));
> createMapView(panel);
> }
>
> public JScrollPane createMapView(JScrollPane panel) {
> JSVGCanvas svgCanvas = new JSVGCanvas();
> panel.add(svgCanvas);
> // Below here, the SVG Event Listeners are set up.
>
> // End MapView class code...
>
> Now this morning when I started futzing with it, it was working up to
> the addGVTTreeRendererListener event not firing... but no errors.
> Now, after messing... it errors out with the following errors:
>
> java.lang.NullPointerException
> at AppMainFrame.loadMapMenuItemActionPerformed(AppMainFrame.java:308)
> at AppMainFrame.access$1(AppMainFrame.java:302)
> at AppMainFrame$2.actionPerformed(AppMainFrame.java:143)
> at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
> at
> javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
>
> at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>
> at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
> at
> javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1113)
> at
> javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)
>
> at java.awt.Component.processMouseEvent(Component.java:5100)
> at java.awt.Component.processEvent(Component.java:4897)
> at java.awt.Container.processEvent(Container.java:1569)
> at java.awt.Component.dispatchEventImpl(Component.java:3615)
> at java.awt.Container.dispatchEventImpl(Container.java:1627)
> at java.awt.Component.dispatchEvent(Component.java:3477)
> at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
> at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
> at java.awt.Container.dispatchEventImpl(Container.java:1613)
> at java.awt.Window.dispatchEventImpl(Window.java:1606)
> at java.awt.Component.dispatchEvent(Component.java:3477)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
> at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
>
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
>
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
>
> This is dying at the try block in the loadMapView() method,
> specifically at the setURI call.
>
> I can zip and send the entire thing so that someone could help me
> figure out what I am doing wrong. My guess is that for some reason,
> the JSVGCanvas component is not properly referenced/linked into the
> application. I have tried setting the JScrollPane's background color,
> as well as the JSVGCanvas, neither of which work... which makes me
> think that this is a simple reference error on my part... but I can't
> find it. :(
>
> Many thanks in advance. Just email me and I can forward the files.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org