Commit 265f538b authored by Sebastien Jourdain's avatar Sebastien Jourdain

Merge branch 'remove-java6-code-style' into remove-java6-code-style-master

Conflicts:
	Wrapping/Java/CMakeLists.txt

Change-Id: I0b768d286eecc05a3d481173e2007c88ff4ac6bb
parents ca5782ac f1a99707
......@@ -136,7 +136,6 @@ public class Focus extends JFrame {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
ActionEvent.CTRL_MASK));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Create a file chooser
final JFileChooser fc = new JFileChooser();
......@@ -156,7 +155,6 @@ public class Focus extends JFrame {
// A JButton
JButton increase = new JButton("Increase Focus");
increase.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
thresh.SetValue(1, thresh.GetValue(1) + 1);
extract.Modified();
......@@ -167,7 +165,6 @@ public class Focus extends JFrame {
// A JButton
JButton decrease = new JButton("Decrease Focus");
decrease.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (thresh.GetValue(1) > 0) {
thresh.SetValue(1, thresh.GetValue(1) - 1);
......
......@@ -150,7 +150,7 @@ public class TreeViews extends JFrame {
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
ActionEvent.CTRL_MASK));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Create a file chooser
final JFileChooser fc = new JFileChooser();
......
......@@ -162,7 +162,7 @@ add_custom_command(
OUTPUT ${VTK_BINARY_DIR}/java/javac_stamp.txt
DEPENDS ${VTK_JAVA_SOURCE_FILES}
COMMAND ${JAVA_COMPILE} ${JAVAC_OPTIONS}
-source 5 -classpath ${VTK_JAVA_HOME}/.. -sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java/ -d ${VTK_BINARY_DIR}/java
-source 1.5 -classpath ${VTK_JAVA_HOME}/.. -sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java/ -d ${VTK_BINARY_DIR}/java
${VTK_BINARY_DIR}/java/vtk/*.java
COMMAND ${CMAKE_COMMAND} -E touch ${VTK_BINARY_DIR}/java/javac_stamp.txt
COMMENT "Compiling Java Classes"
......@@ -200,7 +200,7 @@ if(BUILD_TESTING)
add_custom_command(
OUTPUT ${VTK_BINARY_DIR}/java/javac_tests_stamp.txt
COMMAND ${JAVA_COMPILE} ${JAVAC_OPTIONS} -classpath ${VTK_JAR_PATH}/vtk.jar${SEPARATOR}${VTK_BINARY_DIR}/Wrapping/Java
-sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java
-source 1.5 -sourcepath ${VTK_SOURCE_DIR}/Wrapping/Java
-d ${VTK_BINARY_DIR}/Wrapping/Java
${VTK_JAVA_TESTS}
COMMAND ${CMAKE_COMMAND} -E touch ${VTK_BINARY_DIR}/java/javac_tests_stamp.txt
......
......@@ -75,7 +75,6 @@ public class Demo extends JPanel {
this.actorToAdd = a;
}
@Override
public void run() {
this.renderer.AddActor(this.actorToAdd);
this.panel.Render();
......@@ -89,7 +88,6 @@ public class Demo extends JPanel {
private vtkShrinkFilter shrink;
private vtkSphereSource sphere;
@Override
public vtkActor call() throws Exception {
// New
actor = new vtkActor();
......@@ -157,7 +155,6 @@ public class Demo extends JPanel {
this.nbSeconds = 0;
new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (nbSeconds++ < 10) {
panel3d.resetCamera();
......@@ -190,7 +187,6 @@ public class Demo extends JPanel {
// Start/Stop the GC based on the checkbox
runGC.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
vtkObject.JAVA_OBJECT_MANAGER.getAutoGarbageCollector().SetAutoGarbageCollection(runGC.isSelected());
}
......@@ -198,7 +194,6 @@ public class Demo extends JPanel {
// Change GC mode based on the checkbox
debugMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
vtkObject.JAVA_OBJECT_MANAGER.getAutoGarbageCollector().SetDebug(debugMode.isSelected());
}
......@@ -238,7 +233,6 @@ public class Demo extends JPanel {
// -----------------------------------------------------------------
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Demo app = new Demo();
......
......@@ -166,7 +166,6 @@ public class ImagePlaneWidget extends vtkCanvas {
ImagePlaneWidget.printUsage(f.getAbsolutePath() + " does not exist or cannot be read.");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new ImagePlaneWidget(f.getAbsolutePath() + "/quarter");
}
......
......@@ -170,7 +170,6 @@ public class InternalFrames extends JFrame {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new InternalFrames();
}
......
......@@ -78,7 +78,6 @@ public class ReleaseVtkPanel {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// Setup GC to run every 1 second in EDT
vtkObject.JAVA_OBJECT_MANAGER.getAutoGarbageCollector().SetScheduleTime(5, TimeUnit.SECONDS);
......@@ -88,12 +87,10 @@ public class ReleaseVtkPanel {
JButton startVTKApp = new JButton("Start VTK application");
startVTKApp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final VtkApplication app = new VtkApplication();
JFrame f = buildFrame("VtkApp", app, 400, 200);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
app.Delete();
}
......
......@@ -71,7 +71,6 @@ public class SimpleVTK extends JPanel implements ActionListener {
public static void main(String s[]) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("SimpleVTK");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
......
......@@ -25,7 +25,6 @@ public class ConcurrencyGC {
// Setup working runnable
Runnable workingJob = new Runnable() {
@Override
public void run() {
try {
vtkUnstructuredGrid grid = new vtkUnstructuredGrid();
......
......@@ -18,14 +18,12 @@ public interface vtkJavaMemoryManager {
* Create or return an existing instance of the vtkObject that corresponds
* to the pointer id vtkId.
*
* @param <T>
* Type of the object that we want to return.
* @param vtkId
* is used to uniquely identify a vtkObject inside the C++ layer.
*
* @return a java object that map its underlying C++ instance.
*/
<T extends vtkObjectBase> T getJavaObject(Long vtkId);
vtkObjectBase getJavaObject(Long vtkId);
/**
* Store the Java instance of a vtkObject inside a weak pointer map.
......
......@@ -28,10 +28,8 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
this.garbageCollector = new vtkJavaGarbageCollector();
}
@SuppressWarnings("unchecked")
@Override
// Thread safe
public <T extends vtkObjectBase> T getJavaObject(Long vtkId) {
public vtkObjectBase getJavaObject(Long vtkId) {
// Check pre-condition
if (vtkId == null || vtkId.longValue() == 0) {
throw new RuntimeException("Invalid ID, can not be null or equal to 0.");
......@@ -53,7 +51,7 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
value = objectMap.get(vtkId);
resultObject = (value == null) ? null : value.get();
if (resultObject != null) {
return (T) resultObject;
return resultObject;
}
// We need to do the work of the gc
......@@ -65,9 +63,9 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
if (resultObject == null) {
try {
String className = vtkObjectBase.VTKGetClassNameFromReference(vtkId.longValue());
Class<T> c = (Class<T>) Class.forName("vtk." + className);
Constructor<T> cons = c.getConstructor(new Class[] { long.class });
resultObject = cons.newInstance(new Object[] { vtkId });
Class c = Class.forName("vtk." + className);
Constructor cons = c.getConstructor(new Class[] { long.class });
resultObject = (vtkObjectBase) cons.newInstance(new Object[] { vtkId });
} catch (Exception e) {
e.printStackTrace();
}
......@@ -76,10 +74,9 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
this.lock.unlock();
}
}
return (T) resultObject;
return resultObject;
}
@Override
// Thread safe
public void registerJavaObject(Long id, vtkObjectBase obj) {
try {
......@@ -91,7 +88,6 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
// Thread safe
public void unRegisterJavaObject(Long id) {
try {
......@@ -110,7 +106,6 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
// Thread safe
public vtkReferenceInformation gc(boolean debug) {
System.gc();
......@@ -134,12 +129,10 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
}
}
@Override
public vtkJavaGarbageCollector getAutoGarbageCollector() {
return this.garbageCollector;
}
@Override
// Thread safe
public int deleteAll() {
int size = this.objectMap.size();
......@@ -154,12 +147,10 @@ public class vtkJavaMemoryManagerImpl implements vtkJavaMemoryManager {
return size;
}
@Override
public int getSize() {
return objectMap.size();
}
@Override
public vtkReferenceInformation getLastReferenceInformation() {
return this.lastGcResult;
}
......
......@@ -104,7 +104,6 @@ public class vtkJavaTesting {
public static void StartTimeoutExit(long time, TimeUnit unit) {
ScheduledExecutorService killerThread = Executors.newSingleThreadScheduledExecutor();
Runnable killer = new Runnable() {
@Override
public void run() {
System.exit(0);
}
......
......@@ -104,7 +104,6 @@ public class vtkReferenceInformation {
return builder.toString();
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(50);
builder.append("VTK Gabage Collection: free(");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment