Skip to content

Fix for EDT violations and other small fixes. #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
<classpathentry excluding="**/.DS_Store|**/.cvsignore|build.xml" kind="src" path="src/openmap"/>
<classpathentry kind="src" path="src/vpfservlet/WEB-INF/src"/>
<classpathentry kind="src" path="src/maptileservlet/WEB-INF/src"/>
<classpathentry excluding="**/.DS_Store|**/.cvsignore|build.xml" kind="src" path="src/ext"/>
<classpathentry excluding="**/jai/**|**/geotiff/**" kind="src" output="target/classes" path="src/ext">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**/.DS_Store|**/.cvsignore|build.xml" kind="src" output="classes/corba" path="src/corba"/>
<classpathentry excluding="**/.DS_Store|**/.cvsignore|build.xml" kind="src" output="classes/j3d" path="src/j3d"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
<classpathentry kind="lib" path="ext/batik-1.7/extensions/batik-rasterizer-ext.jar"/>
<classpathentry kind="lib" path="ext/batik-1.7/extensions/batik-squiggle-ext.jar"/>
Expand Down Expand Up @@ -49,5 +58,34 @@
<classpathentry kind="lib" path="ext/sqlitejdbc/sqlitejdbc-v056.jar"/>
<classpathentry kind="lib" path="ext/apache/servlet-api.jar"/>
<classpathentry kind="lib" path="ext/BrowserLauncher2-all-1_3.jar"/>
<classpathentry kind="output" path="classes/openmap"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/classes
/package
/nbproject/private/
/build/
/dist/
*/target/**

/classes/
/target/
/.classpath
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
10 changes: 7 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
Expand All @@ -18,6 +18,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
Expand Down Expand Up @@ -59,6 +60,7 @@ org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
Expand All @@ -84,7 +86,9 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=ignore
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
############################ -->

<target name="init" description="Sets properties needed by the other targets.">

<property name="build.compiler" value="extJavac"/>
<property name="openmap.home" value="." />

<property name="general.excludes" value="**/*.in, **/Makefile, **/*.bat,
Expand Down
81 changes: 81 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bbn.openmap</groupId>
<artifactId>openmap</artifactId>
<packaging>jar</packaging>
<version>5.1.19-SNAPSHOT</version>
<name>openmap</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<!--
<dependency>
<groupId>edu.stanford.ejalbert</groupId>
<artifactId>BrowserLauncher2</artifactId>
<version>1.3</version>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<!-- not test because junit is used outside ../test/ * -->
<scope>provided</scope>
</dependency>
</dependencies>


<build>

<resources>
<resource>
<directory>./src/openmap/</directory>
<includes>
<include>**/*.png</include>
<include>**/*.gif</include>
<include>**/*.jpg</include>
</includes>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/jai/**</exclude>
<exclude>**/geotiff/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>./src/ext</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<sourceDirectory>./src/openmap/com</sourceDirectory>
</build>

</project>
50 changes: 49 additions & 1 deletion src/openmap/com/bbn/openmap/event/AbstractMouseMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.geom.Point2D;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
Expand All @@ -45,6 +46,7 @@
import com.bbn.openmap.MapBean;
import com.bbn.openmap.MouseDelegator;
import com.bbn.openmap.OMComponent;
import com.bbn.openmap.proj.Proj;
import com.bbn.openmap.util.PropUtils;
import com.bbn.openmap.util.propertyEditor.OptionPropertyEditor;

Expand Down Expand Up @@ -108,6 +110,8 @@ public class AbstractMouseMode

protected boolean mouseWheelListener = true;

protected boolean mouseWheelScrollLikeOSM = true;

protected boolean noMouseWheelListenerTimer = false;

protected String prettyName;
Expand Down Expand Up @@ -176,6 +180,12 @@ public class AbstractMouseMode
*/
public static final String MouseWheelTimerIntervalProperty = "mouseWheelTimerInterval";

/**
* scrollwhell zoom like OSM and Google Maps, ie mouse lat,lon is mapped to
* same x,y during scrollwheel zoom
*/
public static final String MouseWheelScrollLikeOSMProperty = "mouseWheelScrollLikeOSM";

/**
* Construct an AbstractMouseMode. Default constructor, allocates the mouse
* support object.
Expand Down Expand Up @@ -460,7 +470,9 @@ public void mouseMoved(MouseEvent e) {
* Invoked from the MouseWheelListener interface.
*/
public void mouseWheelMoved(MouseWheelEvent e) {
if (mouseWheelListener) {
if (mouseWheelListener && mouseWheelScrollLikeOSM) {
scrollWheelZoomLikeOSM(e);
} else if (mouseWheelListener) {
int rot = e.getWheelRotation();
if (e.getSource() instanceof MapBean) {
MapBean mb = (MapBean) e.getSource();
Expand Down Expand Up @@ -680,6 +692,9 @@ public void setProperties(String prefix, Properties props) {

noMouseWheelListenerTimer = PropUtils.booleanFromProperties(props, prefix + NoMouseWheelListenerTimerProperty, noMouseWheelListenerTimer);
mouseWheelTimerInterval = PropUtils.intFromProperties(props, prefix + MouseWheelTimerIntervalProperty, mouseWheelTimerInterval);

mouseWheelScrollLikeOSM = PropUtils.booleanFromProperties(props, prefix
+ MouseWheelScrollLikeOSMProperty, mouseWheelScrollLikeOSM);
}

public Properties getProperties(Properties props) {
Expand Down Expand Up @@ -766,6 +781,8 @@ public Properties getPropertyInfo(Properties props) {
"Setting for the wait interval for the mouse wheel timer",
null);

PropUtils.setI18NPropertyInfo(i18n, props, thisClass, MouseWheelScrollLikeOSMProperty, "Mouse Wheel Zoom like OSM", "Setting for using OSM like zoom", "com.bbn.openmap.util.propertyEditor.YesNoPropertyEditor");

StringBuffer cOptions = new StringBuffer();
Field[] cFields = Cursor.class.getFields();
for (int i = 0; i < cFields.length; i++) {
Expand Down Expand Up @@ -876,4 +893,35 @@ public boolean isNoMouseWheelListenerTimer() {
public void setNoMouseWheelListenerTimer(boolean noMouseWheelListenerTimer) {
this.noMouseWheelListenerTimer = noMouseWheelListenerTimer;
}

/**
* Zoom like G maps and OSM keeping the mouse x,y -> lat,lon constant between
* scale changes instead of just zooming with the center fixed. Avoids having
* to constantly manually recenter the map before/after zooming.
*/
protected void scrollWheelZoomLikeOSM(MouseWheelEvent e) {
if (mouseWheelListener && e.getSource() instanceof MapBean) {
boolean direction = isZoomWhenMouseWheelUp();
float zoomIn = 1.1f;
float zoomOut = .9f;
float amount = zoomIn;
int rot = e.getWheelRotation();
if ((direction && rot < 0) || (!direction && rot > 0)) {
amount = zoomOut;
}
// keep cursor x,y pointing to the same lat,lon after scale
// has been changed
MapBean mapBean = (MapBean) e.getSource();
Proj proj = (Proj) mapBean.getProjection().makeClone();
Point2D mouseLatLon = mapBean.getCoordinates(e);
proj.setScale(mapBean.getScale() * amount);
Point2D newXyCenter = proj.forward(proj.getCenter());
Point2D newXy = proj.forward(mouseLatLon);
Point2D centerWithOffset = new Point2D.Double(newXyCenter.getX()
+ (newXy.getX() - e.getX()), newXyCenter.getY() + (newXy.getY() - e.getY()));
proj.setCenter(proj.inverse(centerWithOffset));
mapBean.setProjection(proj);
}
}

}
3 changes: 3 additions & 0 deletions src/openmap/com/bbn/openmap/event/NavMouseMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ public void mouseDragged(MouseEvent e) {
}

super.mouseDragged(e);
if (point1 == null) {
return;
}

Object obj = e.getSource();

Expand Down
15 changes: 13 additions & 2 deletions src/openmap/com/bbn/openmap/gui/LayerStatusPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;

import com.bbn.openmap.Layer;
import com.bbn.openmap.LayerHandler;
Expand Down Expand Up @@ -74,10 +75,20 @@ protected LayerStatusPane(String title) {
public void updateLayerStatus(LayerStatusEvent evt) {
switch (evt.getStatus()) {
case LayerStatusEvent.START_WORKING:
onoffButton.setSelectedIcon(layerWorking);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
onoffButton.setSelectedIcon(layerWorking);
}
});
break;
case LayerStatusEvent.FINISH_WORKING:
onoffButton.setSelectedIcon(layerDone);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
onoffButton.setSelectedIcon(layerDone);
}
});
break;
}
}
Expand Down
17 changes: 12 additions & 5 deletions src/openmap/com/bbn/openmap/gui/ScaleTextPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.Serializable;

import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import com.bbn.openmap.I18n;
import com.bbn.openmap.MapBean;
Expand Down Expand Up @@ -102,12 +103,18 @@ public synchronized void setProjection(Projection aProjection) {
+ String.valueOf(projection.getScale()) + "\"");
}

String oldScale = scaleField.getText();
String newScale = df.format(projection.getScale());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String oldScale = scaleField.getText();
String newScale = df.format(projection.getScale());

if (!oldScale.equals(newScale)) {
scaleField.setText("1:" + newScale);
}
if (!oldScale.equals(newScale)) {
scaleField.setText("1:" + newScale);
}

}
});
}

/**
Expand Down
Loading