Skip to main content

JDICplus: geocoding? That's VERY easy!

9 replies [Last post]
uta
Offline
Joined: 2007-01-10
Points: 0

Hello BrMap example:
[pre]
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import org.jdic.web.BrMap;
public class EasyMap extends javax.swing.JFrame {
EasyMap()
{
BrMap.DESIGN_MODE = false;
add(new BrMap());
setSize(new Dimension(320,200));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new EasyMap().setVisible(true);
}});
}
}
[/pre]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ranario
Offline
Joined: 2010-10-08
Points: 0

[b]I tried the DocViewDemo.jnlp application and I found in it a functionality of displaying the content of MSWord file as is in the Java application.
I got the source code and tried to run the part that displays MSWord file content but I get an exception, here's the code:[/b]

import java.awt.GraphicsConfiguration;

import javax.swing.JFrame;

import javax.swing.SwingUtilities;
import org.jdic.web.BrComponent;

/*
* DocViewFrame.java
*
* Created on June 18, 2008, 12:34 PM
*/
import org.jdic.web.event.BrComponentEvent;
import org.jdic.web.event.BrComponentListener;

public class DocViewFrame extends javax.swing.JFrame {

public DocViewFrame(String string,
GraphicsConfiguration graphicsConfiguration) {
super(string, graphicsConfiguration);
}

public DocViewFrame(String string) {
super(string);
}

public DocViewFrame(GraphicsConfiguration graphicsConfiguration) {
super(graphicsConfiguration);
}

/** Creates new form DocViewFrame */
public DocViewFrame() {
BrComponent.DESIGN_MODE = false;
BrComponent.setDefaultPaintAlgorithm(BrComponent.PAINT_NATIVE);
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
private void initComponents() {

brView = new org.jdic.web.BrComponent();
tbCommands = new javax.swing.JToolBar();

btMSWord = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Document Viewer");
setName("main"); // NOI18N

brView.setName("viewer"); // NOI18N

javax.swing.GroupLayout brViewLayout = new javax.swing.GroupLayout(brView);
brView.setLayout(brViewLayout);
brViewLayout.setHorizontalGroup(
brViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 397, Short.MAX_VALUE)
);
brViewLayout.setVerticalGroup(
brViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 279, Short.MAX_VALUE)
);

getContentPane().add(brView, java.awt.BorderLayout.CENTER);

tbCommands.setFloatable(false);
tbCommands.setRollover(true);
tbCommands.setMaximumSize(new java.awt.Dimension(10, 20));
tbCommands.setMinimumSize(new java.awt.Dimension(10, 20));
/**start of word part*/
btMSWord.setText("MS Word");
btMSWord.setFocusable(false);
btMSWord.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btMSWord.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btMSWord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btMSWordActionPerformed(evt);
}
});
tbCommands.add(btMSWord);
/**end of word part*/
getContentPane().add(tbCommands, java.awt.BorderLayout.PAGE_END);
// pack();
}// //GEN-END:initComponents

private void btMSWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMSWordActionPerformed
brView.setURL("http://www.aaopt.org/content/docs/course-abstractFAQs.doc");
}//GEN-LAST:event_btMSWordActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DocViewFrame().setVisible(true);//
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private org.jdic.web.BrComponent brView;
private javax.swing.JButton btMSWord;
private javax.swing.JToolBar tbCommands;
// End of variables declaration//GEN-END:variables

}

[b]I get the following exception:[/b]

{Native loader
}Native loader
java.lang.NullPointerException
at org.jdic.NativeExtractor.copyStream(NativeExtractor.java:47)
at org.jdic.NativeExtractor.loadLibruary(NativeExtractor.java:83)
at org.jdic.NativeLoadMgr.loadLibrary(NativeLoadMgr.java:99)
at org.jdic.web.peer.WBrComponentPeer.onAddNotify(WBrComponentPeer.java:534)
at org.jdic.web.BrComponent.addNotify(BrComponent.java:463)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at javax.swing.JRootPane.addNotify(JRootPane.java:735)
at java.awt.Container.addNotify(Container.java:2560)
at java.awt.Window.addNotify(Window.java:645)
at java.awt.Frame.addNotify(Frame.java:470)
at java.awt.Window.show(Window.java:841)
at java.awt.Component.show(Component.java:1447)
at java.awt.Component.setVisible(Component.java:1400)
at java.awt.Window.setVisible(Window.java:824)
at DocViewFrame$2.run(DocViewFrame.java:102)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: org.jdic.web.peer.WBrComponentPeer.initIDs()V
at org.jdic.web.peer.WBrComponentPeer.initIDs(Native Method)
at org.jdic.web.peer.WBrComponentPeer.onAddNotify(WBrComponentPeer.java:536)
at org.jdic.web.BrComponent.addNotify(BrComponent.java:463)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at java.awt.Container.addNotify(Container.java:2560)
at javax.swing.JComponent.addNotify(JComponent.java:4683)
at javax.swing.JRootPane.addNotify(JRootPane.java:735)
at java.awt.Container.addNotify(Container.java:2560)
at java.awt.Window.addNotify(Window.java:645)
at java.awt.Frame.addNotify(Frame.java:470)
at java.awt.Window.show(Window.java:841)
at java.awt.Component.show(Component.java:1447)
at java.awt.Component.setVisible(Component.java:1400)
at java.awt.Window.setVisible(Window.java:824)
at DocViewFrame$2.run(DocViewFrame.java:102)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

[b]I'm using JDeveloper 11g with JDK 6 and on Windows 7 platform 64 bit Professional Edition.
Appreciating your prompt reply.
[/b]

Message was edited by: ranario

ornlintern
Offline
Joined: 2008-06-10
Points: 0

This is exactly what I need... but I keep getting a couple of runtime errors when I try your HelloBrMap example. I've been spinning my wheels on this for a while and would appreciate any insights you may have:

{Native loader
}Native loader
java.lang.NullPointerException
at org.jdic.NativeExtractor.copyStream(NativeExtractor.java:47)
at org.jdic.NativeExtractor.loadLibruary(NativeExtractor.java:88)
at org.jdic.NativeLoadMgr.loadLibrary(NativeLoadMgr.java:99)
at org.jdic.web.peer.WBrComponentPeer.(WBrComponentPeer.java:44)
at org.jdic.web.PeerClassFactory.createBrComponentPeer(PeerClassFactory.java:75)
at org.jdic.web.BrComponent.init(BrComponent.java:319)
at org.jdic.web.BrComponent.(BrComponent.java:330)
at org.jdic.web.BrComponent.(BrComponent.java:339)
at org.jdic.web.BrMap.(BrMap.java:219)
at HelloMap.(HelloMap.java:10)
at HelloMap$1.run(HelloMap.java:31)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: org.jdic.web.peer.WBrComponentPeer.initIDs()V
at org.jdic.web.peer.WBrComponentPeer.initIDs(Native Method)
at org.jdic.web.peer.WBrComponentPeer.(WBrComponentPeer.java:45)
at org.jdic.web.PeerClassFactory.createBrComponentPeer(PeerClassFactory.java:75)
at org.jdic.web.BrComponent.init(BrComponent.java:319)
at org.jdic.web.BrComponent.(BrComponent.java:330)
at org.jdic.web.BrComponent.(BrComponent.java:339)
at org.jdic.web.BrMap.(BrMap.java:219)
at HelloMap.(HelloMap.java:10)
at HelloMap$1.run(HelloMap.java:31)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

uta
Offline
Joined: 2007-01-10
Points: 0

Seems that you are trying to add jdic_native_applet.jar into the classpath.
It is not good idea for standalone application. Just put jdicWeb.dll into the sub-folder bin\ of folder where the JDICplus.jar is.
Or be sure that you have writable %temp% folder and you don't run any other version of JDICplus in parallel. Additionally, please, check your version of jdic_native_applet.jar. It should contains jdicArc.dll inside.

ornlintern
Offline
Joined: 2008-06-10
Points: 0

Perfect! That was exactly my problem. Thank you so much for your help :)
Also - I just want to say that I'm finding this thread [i]incredibly[/i] useful. Your code is very readable, and each iteration adds a clear and distinct functionality.

Another quick question - I'm curious, is it possible to remove the other map toggle buttons from the BrMap? I would like to be able to set the map type and to keep the user from changing it.

Message was edited by: ornlintern

uta
Offline
Joined: 2007-01-10
Points: 0

Synchronized maps with alpha mixing example:

[b][pre]
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.SwingUtilities;
import org.jdic.web.BrMap;
import org.jdic.web.BrMapOver;

public class EasyMapOver extends javax.swing.JFrame {
EasyMapOver(){
BrMap.DESIGN_MODE = false;
BrMap masterMap = new BrMap(
BrMap.MAP_YAHOO, //Yahoo maps provider, BrMap.MAP_MS_LIVE or BrMap.MAP_YAHOO
37.79, -122.48, //San Francisco
12, // from BrMap.ZOOM_MIN(1) to BrMap.ZOOM_MAX(19);
BrMap.VIEW_ROAD | BrMap.VIEW_SATELLITE //hybrid view, BrMap.VIEW_ROAD or BrMap.VIEW_SATELLITE
);

BrMapOver overMap = new BrMapOver();
overMap.setMapProvider(BrMap.MAP_MS_LIVE);
overMap.setSyncMap(masterMap);
overMap.setBounds(new Rectangle(80, 30, 320,200));
overMap.bnZoomMinus.setVisible(false);
overMap.bnZoomPlus.setVisible(false);
overMap.sbZoomLevel.setVisible(false);

masterMap.getCentralPanel().add(overMap);
add(masterMap);
setSize(new Dimension(600,480));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new EasyMapOver().setVisible(true);
}});
}
}
[/pre][/b]

uta
Offline
Joined: 2007-01-10
Points: 0

Java mapplets example:
[b][pre]
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import javax.swing.SwingUtilities;
import org.jdic.web.BrMap;
import org.jdic.web.BrMapBalloonSprite;
import org.jdic.web.BrMapSprite;
public class EasyMapplets extends javax.swing.JFrame {
String stAddress;
BrMap map;

EasyMapplets() {
BrMap.DESIGN_MODE = false;
map = new BrMap() {
@Override
public void onFoundAddress(final String[] args) {
//overwritten default action -
// positioning of found location at the center of map
//super.onFoundAddress(args);
SwingUtilities.invokeLater(new Runnable(){ public void run() {
setZoomLevel(2);
String stCenter = args[2] + "," + args[3];
setViewCenter(stCenter);
new BrMapBalloonSprite(
"Location:
" + stAddress + "",
getPoint(stCenter),
BrMapBalloonSprite.Alignment.LEFT_ALIGNED_ABOVE,
new Dimension(100, 70),
16, 16,
16, 16,
new Color(0F, 0F, 0F),
new Color(1F, 1F, 1F, 0.8F)
).add(map);
}});
}
};
map.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
String stPN = evt.getPropertyName();
if( stPN.equals("mapReady") ){
stAddress = "London, UK";
//map API is ready here! We are trying to find "London, UK" location
// ':' at start means that we aren't interested in return value,
// it's essentially accelerate the call.
// Attention: only double quotes are available in Javascript statements.
map.execJS( ":_findAddress(\"" + stAddress + "\")" );
}
}
});
map.getSprites().add(new MapZeroMeridian(new Color(1f, 0f, 0f)));
map.getSprites().add(new MapEquator(new Color(0f, 0f, 1f)));
add(map);
setSize(new Dimension(480,600));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new EasyMapplets().setVisible(true);
}});
}
}

class MapZeroMeridian extends BrMapSprite {
int iStepCount = 100;
MapZeroMeridian(Color spriteColor){
super("ZeroMeridian", spriteColor);
isPoligon = false;
//block poles
for(int i=5; i<=(iStepCount-5); ++i){
LLs.add( new Point2D.Double(i*180.0/iStepCount - 90.0, 0.0) );
}
}
@Override
public void paint(Graphics g, int[] x, int[] y) {
Graphics2D g2 = (Graphics2D)g.create();
g2.setStroke(new BasicStroke(5));
super.paint(g2, x, y);
g2.dispose();
}
}

class MapEquator extends BrMapSprite {
int iStepCount = 100;
MapEquator(Color spriteColor){
super("Equator", spriteColor);
isPoligon = false;
for(int i=0; i<iStepCount; ++i){
LLs.add( new Point2D.Double(0.0, i*360.0/iStepCount - 180.0));
}
}
@Override
public void paint(Graphics g, int[] x, int[] y) {
Graphics2D g2 = (Graphics2D)g.create();
g2.setStroke(new BasicStroke(5));
super.paint(g2, x, y);
g2.dispose();
}
}
[/pre][/b]

Message was edited by: uta

solit
Offline
Joined: 2008-10-29
Points: 0

Hello Uta,

I want to ask you something. In JDICplus, there is a googleMap.html in the directory of org/jdic/web. And that's the question is it possible to change that file and add some scripts according to my needs? If so, only editing the file is enough or new signing is required!!!

Any help will be appreciated about this question!

uta
Offline
Joined: 2007-01-10
Points: 0

Find location, progress and mouse tracing example:
[b][pre]
import java.awt.Dimension;
import java.awt.geom.Point2D;
import javax.swing.SwingUtilities;
import org.jdic.web.BrMap;
import org.jdic.web.BrMapMousePos;
public class EasyMapToFindLocation extends javax.swing.JFrame {
EasyMapToFindLocation()
{
BrMap.DESIGN_MODE = false;
final BrMap map = new BrMap();
map.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
String stPN = evt.getPropertyName();
if( stPN.equals("progressBar") ){
//you can show the progress information here
String stNV = (String)evt.getNewValue();
if(null==stNV)
stNV = "";
String st[] = stNV.split(",");
int iMax = Integer.parseInt(st[0]),
iPos = Integer.parseInt(st[1]);
if(0==iMax){
System.out.println("download complite");
} else {
System.out.printf("...download progress %3.3f%%\n", ((iPos*100.0/iMax)) );
}
} else if( stPN.equals("mouseGeoPos") ){
//you can show the geo coordinates of mouse position here
Point2D gp = ((BrMapMousePos)evt.getNewValue()).getMouseGeoPos();
System.out.printf("mouse location (Latitude:%3.3f, Longitude:%3.3f)\n",
gp.getX(), gp.getY() );
} else if( stPN.equals("mapReady") ){
//map API is ready here! We are trying to find "London, UK" location
// ':' at start means that we aren't interested in return value,
// it's essentially accelerate the call.
// Attention: only double quotes are available in Javascript statements.
map.execJS( ":_findAddress(\"London, UK\")" );
}
}
});
add(map);
setSize(new Dimension(480,600));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new EasyMapToFindLocation().setVisible(true);
}});
}
}
[/pre][/b]

uta
Offline
Joined: 2007-01-10
Points: 0

Adjusted map example:

[b][pre]
import java.awt.Dimension;
import javax.swing.SwingUtilities;
import org.jdic.web.BrMap;
public class EasyMapWithCenterAndZoomLevel extends javax.swing.JFrame {
EasyMapWithCenterAndZoomLevel()
{
BrMap.DESIGN_MODE = false;
BrMap map;
if(true){
map = new BrMap(
BrMap.MAP_GOOGLE, //Google maps provider, BrMap.MAP_MS_LIVE or BrMap.MAP_YAHOO
50.08, 14.44, //Prague
12, // from BrMap.ZOOM_MIN(1) to BrMap.ZOOM_MAX(19);
BrMap.VIEW_ROAD | BrMap.VIEW_SATELLITE //hybrid view, BrMap.VIEW_ROAD or BrMap.VIEW_SATELLITE
);
} else {
//alternative postponed initialization
map = new BrMap();
map.setInitView(
BrMap.MAP_GOOGLE, //BrMap.MAP_MS_LIVE or BrMap.MAP_YAHOO
50.08, 14.44, //Prague
12, // from BrMap.ZOOM_MIN(1) to BrMap.ZOOM_MAX(19);
BrMap.VIEW_ROAD | BrMap.VIEW_SATELLITE);
}
add(map);
setSize(new Dimension(480,600));
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {public void run() {
new EasyMapWithCenterAndZoomLevel().setVisible(true);
}});
}
}
[pre][/b]