Hi, thanks for your responses. I guess I was just hacking away to try
to get the thing to work. The main problem, though, is that there
aren't a lot of comments in the javadoc to go by, so it's mainly just
guesswork.
Because the application I'm developing is for use in human
experiments, I need very strict control over what the user (in this
case experiment subject) gets to see. This is reason I'm trying to do
it without including the rest of the baggage from the rest of program.
The LayerViewPanel is added to the frame in the line:
frame.add(view, BorderLayout.CENTER);
The result of running the code is:
(1) the shapefile seems to be loaded OK because the line:
System.out.println("New layer has " + features.size() + " features");
... yields:
New layer has 41 features
(2) a window with the title "Jump Test" appears, 640 x 480 in
dimensions and with a white background colour (which a believe is
Jump's default canvas colour).
Interestingly, when I hover over the window with my mouse I get the
following exception thrown :
-------------[ start exception ]----------------
java.awt.geom.NoninvertibleTransformException: Determinant is 0
at
java.awt.geom.AffineTransform.inverseTransform(AffineTransform.java:
3466)
at
com.vividsolutions.jump.workbench.ui.Viewport.toModelPoint(Viewport.java:
174)
at com.vividsolutions.jump.workbench.ui.LayerViewPanel
$2.mouseLocationChanged(LayerViewPanel.java:141)
at com.vividsolutions.jump.workbench.ui.LayerViewPanel
$2.mouseMoved(LayerViewPanel.java:136)
at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:
312)
at java.awt.Component.processMouseMotionEvent(Component.java:6083)
at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:
3283)
at java.awt.Component.processEvent(Component.java:5807)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:
4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:
3999)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:
273)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:
183)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:
173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
----------[ end exception ]-----------
.. which must be something to do with event handlers trying to handle
mouse motions and no code to deal with it. Removing the mouse motion
listeners is a quick fix:
------------[ start code ]--------------
MouseMotionListener[] listeners = view.getMouseMotionListeners();
for(int i = 0; i < listeners.length; i++){
view.removeMouseMotionListener(listeners[i]);
}
----------[ end code ]----------------
Because the problem is visual, its quite difficult to debug. A couple
lines of enquiry are:
(1) ensure the zoom level is correct
(2) ensure the layer view is panned to the data's location
(3) ensure the renderer is applying some kind of style to make it
visible
I'll come back if I make any progress. If anyone has any breakthroughs
do let me know.
Regards,
Conrad
On Nov 4, 4:16 pm, "Sunburned Surveyor" <
sunburned.surve...@gmail.com>
wrote:
> Conrad,
>
> I'm also interested in what you are trying to do. It would be nifty if
> we could package the LayerViewPanel as a working viewer of Features
> with as little baggage as possible.
>
> As Larry mentioned, this may be harder to do than it sounds. In the
> code you pasted above, I didn't see where you added the LayerViewPanel
> to your JFrame. Did I miss that part of your code?
>
> It might be helpful if you past the rest of your code. What happens
> when you run your main method? Is an exception thrown? Does the JFrame
> display? There are a lot of things that could go wrong with the code
> above, or code that might be missing. If we have the rest of the
> application we might be able to figure this out.
>
> The Sunburned Surveyor
>
> On Tue, Nov 4, 2008 at 6:45 AM, Larry Becker <
becker.la...@gmail.com> wrote:
> > Hi Conrad,
>
> > Wow, it would be great if you could make a GIS viewer based on JUMP with
> > that little code! I suspect the answer is much more complex. I'm not aware
> > of any prior efforts that have succeeded without carrying the rest of the
> > baggage along too. I know that the JUMP developers guide touts the
> > LayerViewPanel as a component that can be used in other applications, so
> > perhaps it can be done. We're rooting for you. If you have any specific
> > questions, just ask.
>
> > regards,
> > Larry Becker
>