Re-worked the jobs service to include UI and GL pools default tip
authorJosh Reed <jareed@andrill.org>
Fri Jan 02 10:40:41 2009 -0600 (3 years ago)
changeset 29125e8cee54463
parent 290 8d8bb7618840
Re-worked the jobs service to include UI and GL pools
org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/dataset/renderables/LineGraphRenderable.java
org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/handlers/expedition/ui/ExpeditionPanel.java
org.andrill.visualizer.core/META-INF/MANIFEST.MF
org.andrill.visualizer.core/build.properties
org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/Activator.java
org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/job/JobService.java
org.andrill.visualizer.core/src/org/andrill/visualizer/core/job/IJobService.java
org.andrill.visualizer.core/src/org/andrill/visualizer/core/job/IJobs.java
org.andrill.visualizer.ui.image/src/org/andrill/visualizer/ui/image/ImageRenderable.java
org.andrill.visualizer.ui/src/org/andrill/visualizer/ui/internal/camera/GLTile.java
     1.1 --- a/org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/dataset/renderables/LineGraphRenderable.java	Wed Dec 31 14:58:36 2008 -0600
     1.2 +++ b/org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/dataset/renderables/LineGraphRenderable.java	Fri Jan 02 10:40:41 2009 -0600
     1.3 @@ -14,7 +14,8 @@
     1.4  import javax.media.opengl.GL;
     1.5  import javax.media.opengl.GLContext;
     1.6  
     1.7 -import org.andrill.visualizer.core.job.IJobService;
     1.8 +import org.andrill.visualizer.core.job.IJobs;
     1.9 +import org.andrill.visualizer.core.job.IJobs.Pool;
    1.10  import org.andrill.visualizer.core.resource.IResource;
    1.11  import org.andrill.visualizer.cores.dataset.DepthValueDataSet;
    1.12  import org.andrill.visualizer.cores.dataset.DepthValueDatum;
    1.13 @@ -58,7 +59,7 @@
    1.14  		this.guessBreaks = guessBreaks;
    1.15  
    1.16  		final Activator a = Activator.getDefault();
    1.17 -		parseJob = a.getService(IJobService.class).submit(job, IJobService.CPU);
    1.18 +		parseJob = a.getService(IJobs.class).submit(job, Pool.CPU);
    1.19  		setBounds(NO_BOUNDS);
    1.20  	}
    1.21  
     2.1 --- a/org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/handlers/expedition/ui/ExpeditionPanel.java	Wed Dec 31 14:58:36 2008 -0600
     2.2 +++ b/org.andrill.visualizer.app.cores/src/org/andrill/visualizer/cores/handlers/expedition/ui/ExpeditionPanel.java	Fri Jan 02 10:40:41 2009 -0600
     2.3 @@ -1,1 +1,1 @@
     2.4 -package org.andrill.visualizer.cores.handlers.expedition.ui;
     2.5 
     2.6 import java.awt.Window;
     2.7 import java.awt.event.ActionEvent;
     2.8 import java.awt.event.ActionListener;
     2.9 import java.awt.geom.Rectangle2D;
    2.10 import java.io.IOException;
    2.11 import java.io.InputStream;
    2.12 import java.net.URL;
    2.13 import java.util.ArrayList;
    2.14 import java.util.List;
    2.15 import java.util.concurrent.Callable;
    2.16 
    2.17 import javax.swing.JButton;
    2.18 import javax.swing.JLabel;
    2.19 import javax.swing.JOptionPane;
    2.20 import javax.swing.JPanel;
    2.21 import javax.swing.JScrollPane;
    2.22 import javax.swing.JTable;
    2.23 import javax.swing.JTextField;
    2.24 import javax.swing.SwingUtilities;
    2.25 
    2.26 import org.andrill.visualizer.core.io.IOUtils;
    2.27 import org.andrill.visualizer.core.job.IJobService;
    2.28 import org.andrill.visualizer.core.resource.IResource;
    2.29 import org.andrill.visualizer.core.resource.IResourceParser;
    2.30 import org.andrill.visualizer.core.resource.ResourceUtils;
    2.31 import org.andrill.visualizer.cores.handlers.expedition.Expedition;
    2.32 import org.andrill.visualizer.cores.handlers.expedition.FeedResource;
    2.33 import org.andrill.visualizer.cores.internal.Activator;
    2.34 import org.andrill.visualizer.ui.camera.ICamera;
    2.35 import org.jdesktop.layout.GroupLayout;
    2.36 import org.jdesktop.layout.LayoutStyle;
    2.37 import org.osgi.framework.BundleContext;
    2.38 
    2.39 import ca.odell.glazedlists.EventList;
    2.40 import ca.odell.glazedlists.GlazedLists;
    2.41 import ca.odell.glazedlists.SortedList;
    2.42 import ca.odell.glazedlists.swing.EventTableModel;
    2.43 import ca.odell.glazedlists.swing.TableComparatorChooser;
    2.44 
    2.45 /**
    2.46  * A panel for Expedition component nodes.
    2.47  * 
    2.48  * @author Josh Reed (jareed@andrill.org)
    2.49  */
    2.50 public class ExpeditionPanel extends JPanel {
    2.51 	private static final long serialVersionUID = 1L;
    2.52 	private JTextField depthField;
    2.53 	private JLabel depthLabel;
    2.54 	private Expedition expedition;
    2.55 	private final EventList<FeedResource> feeds;
    2.56 	private JTable feedTable;
    2.57 	private JLabel instLabel1;
    2.58 	private JLabel instLabel2;
    2.59 	private JScrollPane scrollPane;
    2.60 	private final List<FeedResource> selected;
    2.61 	private JButton setButton;
    2.62 
    2.63 	/**
    2.64 	 * Creates new form ExpeditionPanel
    2.65 	 */
    2.66 	public ExpeditionPanel(final Expedition expedition) {
    2.67 		// save our variables
    2.68 		this.expedition = expedition;
    2.69 		feeds = GlazedLists.eventList(expedition.getFeeds());
    2.70 		selected = new ArrayList<FeedResource>();
    2.71 
    2.72 		// initialize our components
    2.73 		initComponents();
    2.74 	}
    2.75 
    2.76 	private void addResources(final DepthRange range) {
    2.77 		// get our context and our job service
    2.78 		final BundleContext context = Activator.getDefault().getContext();
    2.79 		final IJobService jobs = Activator.getDefault().getService(
    2.80 				IJobService.class);
    2.81 		if (jobs == null) {
    2.82 			return;
    2.83 		}
    2.84 
    2.85 		// update the camera position
    2.86 		// zoom out
    2.87 		final ICamera camera = Activator.getDefault().getService(ICamera.class);
    2.88 		camera.lookAt(new Rectangle2D.Double(range.getTop(), -1.0, range
    2.89 				.getBottom()
    2.90 				- range.getTop(), 2.0));
    2.91 
    2.92 		// walk through the selected feeds and parse the resources
    2.93 		for (final FeedResource feed : selected) {
    2.94 			// HACK: pre-fetch to trigger the URL auth dialog on the EDT so we
    2.95 			// can peel off into a thread later
    2.96 			prefetch(feed.getURL());
    2.97 
    2.98 			// get the parser
    2.99 			final IResourceParser parser = ResourceUtils.getParser(context,
   2.100 					feed.getType());
   2.101 			if (parser != null) {
   2.102 				// get the contents from the resource parser in a concurrent job
   2.103 				jobs.submit(new Callable<Void>() {
   2.104 					public Void call() throws Exception {
   2.105 						// get the contents of the feed
   2.106 						final List<IResource> contents = parser.getResources(
   2.107 								feed.getURL(), feed.getResource(), feed
   2.108 										.getProperties());
   2.109 
   2.110 						// walk through the contents and add all those in range
   2.111 						for (final IResource r : contents) {
   2.112 							ResourceUtils.addResource(context, r);
   2.113 						}
   2.114 						return null;
   2.115 					}
   2.116 				}, IJobService.CPU);
   2.117 			}
   2.118 		}
   2.119 	}
   2.120 
   2.121 	private void initComponents() {
   2.122 		// create our components
   2.123 		depthLabel = new JLabel();
   2.124 		depthField = new JTextField();
   2.125 		scrollPane = new JScrollPane();
   2.126 		feedTable = new JTable();
   2.127 		setButton = new JButton();
   2.128 
   2.129 		// configure the components
   2.130 		depthLabel.setText("Depth Range:");
   2.131 		scrollPane.setViewportView(feedTable);
   2.132 		setButton.setText("Set");
   2.133 		setButton.addActionListener(new ActionListener() {
   2.134 			public void actionPerformed(final ActionEvent e) {
   2.135 				onSet();
   2.136 			}
   2.137 		});
   2.138 		depthField.addActionListener(new ActionListener() {
   2.139 			public void actionPerformed(final ActionEvent e) {
   2.140 				onSet();
   2.141 			}
   2.142 		});
   2.143 
   2.144 		// configure the table
   2.145 		final SortedList<FeedResource> sorted = new SortedList<FeedResource>(
   2.146 				feeds, null);
   2.147 		feedTable.setModel(new EventTableModel<FeedResource>(sorted,
   2.148 				new ResourceTableFormat(selected)));
   2.149 		new TableComparatorChooser<FeedResource>(feedTable, sorted, false);
   2.150 		feedTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
   2.151 		feedTable.getColumnModel().getColumn(0).setPreferredWidth(50);
   2.152 		feedTable.getColumnModel().getColumn(1).setPreferredWidth(400);
   2.153 
   2.154 		instLabel1 = new JLabel("Select the data/images you are interested in:");
   2.155 		instLabel2 = new JLabel("Set the depth range (e.g., 0-100, < 10, >0):");
   2.156 
   2.157 		// layout the components
   2.158 		final GroupLayout layout = new GroupLayout(this);
   2.159 		setLayout(layout);
   2.160 		layout
   2.161 				.setHorizontalGroup(layout
   2.162 						.createParallelGroup(GroupLayout.LEADING)
   2.163 						.add(
   2.164 								layout
   2.165 										.createSequentialGroup()
   2.166 										.addContainerGap()
   2.167 										.add(
   2.168 												layout
   2.169 														.createParallelGroup(
   2.170 																GroupLayout.LEADING)
   2.171 														.add(
   2.172 																layout
   2.173 																		.createSequentialGroup()
   2.174 																		.add(
   2.175 																				scrollPane,
   2.176 																				GroupLayout.DEFAULT_SIZE,
   2.177 																				468,
   2.178 																				Short.MAX_VALUE)
   2.179 																		.addContainerGap())
   2.180 														.add(
   2.181 																layout
   2.182 																		.createSequentialGroup()
   2.183 																		.add(
   2.184 																				depthLabel)
   2.185 																		.addPreferredGap(
   2.186 																				LayoutStyle.RELATED)
   2.187 																		.add(
   2.188 																				depthField,
   2.189 																				GroupLayout.DEFAULT_SIZE,
   2.190 																				290,
   2.191 																				Short.MAX_VALUE)
   2.192 																		.addPreferredGap(
   2.193 																				LayoutStyle.RELATED)
   2.194 																		.add(
   2.195 																				setButton)
   2.196 																		.add(
   2.197 																				20,
   2.198 																				20,
   2.199 																				20))
   2.200 														.add(
   2.201 																layout
   2.202 																		.createSequentialGroup()
   2.203 																		.add(
   2.204 																				instLabel1)
   2.205 																		.addContainerGap(
   2.206 																				207,
   2.207 																				Short.MAX_VALUE))
   2.208 														.add(
   2.209 																layout
   2.210 																		.createSequentialGroup()
   2.211 																		.add(
   2.212 																				instLabel2)
   2.213 																		.addContainerGap(
   2.214 																				215,
   2.215 																				Short.MAX_VALUE)))));
   2.216 		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING)
   2.217 				.add(
   2.218 						GroupLayout.TRAILING,
   2.219 						layout.createSequentialGroup().addContainerGap().add(
   2.220 								instLabel1)
   2.221 								.addPreferredGap(LayoutStyle.RELATED).add(
   2.222 										scrollPane, GroupLayout.DEFAULT_SIZE,
   2.223 										178, Short.MAX_VALUE).add(18, 18, 18)
   2.224 								.add(instLabel2).addPreferredGap(
   2.225 										LayoutStyle.RELATED).add(
   2.226 										layout.createParallelGroup(
   2.227 												GroupLayout.BASELINE).add(
   2.228 												depthLabel).add(depthField,
   2.229 												GroupLayout.PREFERRED_SIZE,
   2.230 												GroupLayout.DEFAULT_SIZE,
   2.231 												GroupLayout.PREFERRED_SIZE)
   2.232 												.add(setButton))
   2.233 								.addContainerGap()));
   2.234 	}
   2.235 
   2.236 	protected void onSet() {
   2.237 		// parse the expression
   2.238 		final SimpleExpression expression = SimpleExpression.parse(depthField
   2.239 				.getText());
   2.240 		if (expression == null) {
   2.241 			JOptionPane
   2.242 					.showMessageDialog(
   2.243 							this,
   2.244 							"Invalid depth expression.  Try something like '<100', '>0', or '0-100'",
   2.245 							"Error", JOptionPane.ERROR_MESSAGE);
   2.246 		} else {
   2.247 			// parse our operands
   2.248 			double op1 = 0.0;
   2.249 			if (SimpleExpression.isNumber(expression.getOperand1())) {
   2.250 				op1 = Double.parseDouble(expression.getOperand1());
   2.251 			}
   2.252 			double op2 = 0.0;
   2.253 			if (SimpleExpression.isNumber(expression.getOperand2())) {
   2.254 				op2 = Double.parseDouble(expression.getOperand2());
   2.255 			}
   2.256 
   2.257 			// setup our range
   2.258 			final DepthRange range = new DepthRange();
   2.259 			if (expression.getOperator().equals("<")) {
   2.260 				range.setTop(Double.MIN_VALUE);
   2.261 				range.setBottom(op1);
   2.262 			} else if (expression.getOperator().equals(">")) {
   2.263 				range.setTop(op1);
   2.264 				range.setBottom(Double.MAX_VALUE);
   2.265 			} else if (expression.getOperator().equals("-")) {
   2.266 				range.setTop(op1);
   2.267 				range.setBottom(op2);
   2.268 			} else {
   2.269 				range.setTop(op1);
   2.270 				range.setBottom(op1);
   2.271 			}
   2.272 
   2.273 			// add all the matching resources
   2.274 			addResources(range);
   2.275 		}
   2.276 	}
   2.277 
   2.278 	private void prefetch(final URL url) {
   2.279 		// hide our window
   2.280 		final boolean hide = expedition.getPath().getProtocol().equals("file");
   2.281 		final Window w = SwingUtilities.windowForComponent(this);
   2.282 		if (hide && (w != null)) {
   2.283 			w.setVisible(false);
   2.284 		}
   2.285 
   2.286 		InputStream stream = null;
   2.287 		try {
   2.288 			stream = url.openStream();
   2.289 		} catch (final IOException e) {
   2.290 			// ignore
   2.291 		} finally {
   2.292 			IOUtils.silentClose(stream);
   2.293 
   2.294 			// show our window
   2.295 			if (hide && (w != null)) {
   2.296 				w.setVisible(true);
   2.297 			}
   2.298 		}
   2.299 	}
   2.300 }
   2.301 \ No newline at end of file
   2.302 +package org.andrill.visualizer.cores.handlers.expedition.ui;
   2.303 
   2.304 import java.awt.Window;
   2.305 import java.awt.event.ActionEvent;
   2.306 import java.awt.event.ActionListener;
   2.307 import java.awt.geom.Rectangle2D;
   2.308 import java.io.IOException;
   2.309 import java.io.InputStream;
   2.310 import java.net.URL;
   2.311 import java.util.ArrayList;
   2.312 import java.util.List;
   2.313 import java.util.concurrent.Callable;
   2.314 
   2.315 import javax.swing.JButton;
   2.316 import javax.swing.JLabel;
   2.317 import javax.swing.JOptionPane;
   2.318 import javax.swing.JPanel;
   2.319 import javax.swing.JScrollPane;
   2.320 import javax.swing.JTable;
   2.321 import javax.swing.JTextField;
   2.322 import javax.swing.SwingUtilities;
   2.323 
   2.324 import org.andrill.visualizer.core.io.IOUtils;
   2.325 import org.andrill.visualizer.core.job.IJobs;
   2.326 import org.andrill.visualizer.core.job.IJobs.Pool;
   2.327 import org.andrill.visualizer.core.resource.IResource;
   2.328 import org.andrill.visualizer.core.resource.IResourceParser;
   2.329 import org.andrill.visualizer.core.resource.ResourceUtils;
   2.330 import org.andrill.visualizer.cores.handlers.expedition.Expedition;
   2.331 import org.andrill.visualizer.cores.handlers.expedition.FeedResource;
   2.332 import org.andrill.visualizer.cores.internal.Activator;
   2.333 import org.andrill.visualizer.ui.camera.ICamera;
   2.334 import org.jdesktop.layout.GroupLayout;
   2.335 import org.jdesktop.layout.LayoutStyle;
   2.336 import org.osgi.framework.BundleContext;
   2.337 
   2.338 import ca.odell.glazedlists.EventList;
   2.339 import ca.odell.glazedlists.GlazedLists;
   2.340 import ca.odell.glazedlists.SortedList;
   2.341 import ca.odell.glazedlists.swing.EventTableModel;
   2.342 import ca.odell.glazedlists.swing.TableComparatorChooser;
   2.343 
   2.344 /**
   2.345  * A panel for Expedition component nodes.
   2.346  * 
   2.347  * @author Josh Reed (jareed@andrill.org)
   2.348  */
   2.349 public class ExpeditionPanel extends JPanel {
   2.350 	private static final long serialVersionUID = 1L;
   2.351 	private JTextField depthField;
   2.352 	private JLabel depthLabel;
   2.353 	private Expedition expedition;
   2.354 	private final EventList<FeedResource> feeds;
   2.355 	private JTable feedTable;
   2.356 	private JLabel instLabel1;
   2.357 	private JLabel instLabel2;
   2.358 	private JScrollPane scrollPane;
   2.359 	private final List<FeedResource> selected;
   2.360 	private JButton setButton;
   2.361 
   2.362 	/**
   2.363 	 * Creates new form ExpeditionPanel
   2.364 	 */
   2.365 	public ExpeditionPanel(final Expedition expedition) {
   2.366 		// save our variables
   2.367 		this.expedition = expedition;
   2.368 		feeds = GlazedLists.eventList(expedition.getFeeds());
   2.369 		selected = new ArrayList<FeedResource>();
   2.370 
   2.371 		// initialize our components
   2.372 		initComponents();
   2.373 	}
   2.374 
   2.375 	private void addResources(final DepthRange range) {
   2.376 		// get our context and our job service
   2.377 		final BundleContext context = Activator.getDefault().getContext();
   2.378 		final IJobs jobs = Activator.getDefault().getService(
   2.379 				IJobs.class);
   2.380 		if (jobs == null) {
   2.381 			return;
   2.382 		}
   2.383 
   2.384 		// update the camera position
   2.385 		// zoom out
   2.386 		final ICamera camera = Activator.getDefault().getService(ICamera.class);
   2.387 		camera.lookAt(new Rectangle2D.Double(range.getTop(), -1.0, range
   2.388 				.getBottom()
   2.389 				- range.getTop(), 2.0));
   2.390 
   2.391 		// walk through the selected feeds and parse the resources
   2.392 		for (final FeedResource feed : selected) {
   2.393 			// HACK: pre-fetch to trigger the URL auth dialog on the EDT so we
   2.394 			// can peel off into a thread later
   2.395 			prefetch(feed.getURL());
   2.396 
   2.397 			// get the parser
   2.398 			final IResourceParser parser = ResourceUtils.getParser(context,
   2.399 					feed.getType());
   2.400 			if (parser != null) {
   2.401 				// get the contents from the resource parser in a concurrent job
   2.402 				jobs.submit(new Callable<Void>() {
   2.403 					public Void call() throws Exception {
   2.404 						// get the contents of the feed
   2.405 						final List<IResource> contents = parser.getResources(
   2.406 								feed.getURL(), feed.getResource(), feed
   2.407 										.getProperties());
   2.408 
   2.409 						// walk through the contents and add all those in range
   2.410 						for (final IResource r : contents) {
   2.411 							ResourceUtils.addResource(context, r);
   2.412 						}
   2.413 						return null;
   2.414 					}
   2.415 				}, Pool.CPU);
   2.416 			}
   2.417 		}
   2.418 	}
   2.419 
   2.420 	private void initComponents() {
   2.421 		// create our components
   2.422 		depthLabel = new JLabel();
   2.423 		depthField = new JTextField();
   2.424 		scrollPane = new JScrollPane();
   2.425 		feedTable = new JTable();
   2.426 		setButton = new JButton();
   2.427 
   2.428 		// configure the components
   2.429 		depthLabel.setText("Depth Range:");
   2.430 		scrollPane.setViewportView(feedTable);
   2.431 		setButton.setText("Set");
   2.432 		setButton.addActionListener(new ActionListener() {
   2.433 			public void actionPerformed(final ActionEvent e) {
   2.434 				onSet();
   2.435 			}
   2.436 		});
   2.437 		depthField.addActionListener(new ActionListener() {
   2.438 			public void actionPerformed(final ActionEvent e) {
   2.439 				onSet();
   2.440 			}
   2.441 		});
   2.442 
   2.443 		// configure the table
   2.444 		final SortedList<FeedResource> sorted = new SortedList<FeedResource>(
   2.445 				feeds, null);
   2.446 		feedTable.setModel(new EventTableModel<FeedResource>(sorted,
   2.447 				new ResourceTableFormat(selected)));
   2.448 		new TableComparatorChooser<FeedResource>(feedTable, sorted, false);
   2.449 		feedTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
   2.450 		feedTable.getColumnModel().getColumn(0).setPreferredWidth(50);
   2.451 		feedTable.getColumnModel().getColumn(1).setPreferredWidth(400);
   2.452 
   2.453 		instLabel1 = new JLabel("Select the data/images you are interested in:");
   2.454 		instLabel2 = new JLabel("Set the depth range (e.g., 0-100, < 10, >0):");
   2.455 
   2.456 		// layout the components
   2.457 		final GroupLayout layout = new GroupLayout(this);
   2.458 		setLayout(layout);
   2.459 		layout
   2.460 				.setHorizontalGroup(layout
   2.461 						.createParallelGroup(GroupLayout.LEADING)
   2.462 						.add(
   2.463 								layout
   2.464 										.createSequentialGroup()
   2.465 										.addContainerGap()
   2.466 										.add(
   2.467 												layout
   2.468 														.createParallelGroup(
   2.469 																GroupLayout.LEADING)
   2.470 														.add(
   2.471 																layout
   2.472 																		.createSequentialGroup()
   2.473 																		.add(
   2.474 																				scrollPane,
   2.475 																				GroupLayout.DEFAULT_SIZE,
   2.476 																				468,
   2.477 																				Short.MAX_VALUE)
   2.478 																		.addContainerGap())
   2.479 														.add(
   2.480 																layout
   2.481 																		.createSequentialGroup()
   2.482 																		.add(
   2.483 																				depthLabel)
   2.484 																		.addPreferredGap(
   2.485 																				LayoutStyle.RELATED)
   2.486 																		.add(
   2.487 																				depthField,
   2.488 																				GroupLayout.DEFAULT_SIZE,
   2.489 																				290,
   2.490 																				Short.MAX_VALUE)
   2.491 																		.addPreferredGap(
   2.492 																				LayoutStyle.RELATED)
   2.493 																		.add(
   2.494 																				setButton)
   2.495 																		.add(
   2.496 																				20,
   2.497 																				20,
   2.498 																				20))
   2.499 														.add(
   2.500 																layout
   2.501 																		.createSequentialGroup()
   2.502 																		.add(
   2.503 																				instLabel1)
   2.504 																		.addContainerGap(
   2.505 																				207,
   2.506 																				Short.MAX_VALUE))
   2.507 														.add(
   2.508 																layout
   2.509 																		.createSequentialGroup()
   2.510 																		.add(
   2.511 																				instLabel2)
   2.512 																		.addContainerGap(
   2.513 																				215,
   2.514 																				Short.MAX_VALUE)))));
   2.515 		layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING)
   2.516 				.add(
   2.517 						GroupLayout.TRAILING,
   2.518 						layout.createSequentialGroup().addContainerGap().add(
   2.519 								instLabel1)
   2.520 								.addPreferredGap(LayoutStyle.RELATED).add(
   2.521 										scrollPane, GroupLayout.DEFAULT_SIZE,
   2.522 										178, Short.MAX_VALUE).add(18, 18, 18)
   2.523 								.add(instLabel2).addPreferredGap(
   2.524 										LayoutStyle.RELATED).add(
   2.525 										layout.createParallelGroup(
   2.526 												GroupLayout.BASELINE).add(
   2.527 												depthLabel).add(depthField,
   2.528 												GroupLayout.PREFERRED_SIZE,
   2.529 												GroupLayout.DEFAULT_SIZE,
   2.530 												GroupLayout.PREFERRED_SIZE)
   2.531 												.add(setButton))
   2.532 								.addContainerGap()));
   2.533 	}
   2.534 
   2.535 	protected void onSet() {
   2.536 		// parse the expression
   2.537 		final SimpleExpression expression = SimpleExpression.parse(depthField
   2.538 				.getText());
   2.539 		if (expression == null) {
   2.540 			JOptionPane
   2.541 					.showMessageDialog(
   2.542 							this,
   2.543 							"Invalid depth expression.  Try something like '<100', '>0', or '0-100'",
   2.544 							"Error", JOptionPane.ERROR_MESSAGE);
   2.545 		} else {
   2.546 			// parse our operands
   2.547 			double op1 = 0.0;
   2.548 			if (SimpleExpression.isNumber(expression.getOperand1())) {
   2.549 				op1 = Double.parseDouble(expression.getOperand1());
   2.550 			}
   2.551 			double op2 = 0.0;
   2.552 			if (SimpleExpression.isNumber(expression.getOperand2())) {
   2.553 				op2 = Double.parseDouble(expression.getOperand2());
   2.554 			}
   2.555 
   2.556 			// setup our range
   2.557 			final DepthRange range = new DepthRange();
   2.558 			if (expression.getOperator().equals("<")) {
   2.559 				range.setTop(Double.MIN_VALUE);
   2.560 				range.setBottom(op1);
   2.561 			} else if (expression.getOperator().equals(">")) {
   2.562 				range.setTop(op1);
   2.563 				range.setBottom(Double.MAX_VALUE);
   2.564 			} else if (expression.getOperator().equals("-")) {
   2.565 				range.setTop(op1);
   2.566 				range.setBottom(op2);
   2.567 			} else {
   2.568 				range.setTop(op1);
   2.569 				range.setBottom(op1);
   2.570 			}
   2.571 
   2.572 			// add all the matching resources
   2.573 			addResources(range);
   2.574 		}
   2.575 	}
   2.576 
   2.577 	private void prefetch(final URL url) {
   2.578 		// hide our window
   2.579 		final boolean hide = expedition.getPath().getProtocol().equals("file");
   2.580 		final Window w = SwingUtilities.windowForComponent(this);
   2.581 		if (hide && (w != null)) {
   2.582 			w.setVisible(false);
   2.583 		}
   2.584 
   2.585 		InputStream stream = null;
   2.586 		try {
   2.587 			stream = url.openStream();
   2.588 		} catch (final IOException e) {
   2.589 			// ignore
   2.590 		} finally {
   2.591 			IOUtils.silentClose(stream);
   2.592 
   2.593 			// show our window
   2.594 			if (hide && (w != null)) {
   2.595 				w.setVisible(true);
   2.596 			}
   2.597 		}
   2.598 	}
   2.599 }
   2.600 \ No newline at end of file
     3.1 --- a/org.andrill.visualizer.core/META-INF/MANIFEST.MF	Wed Dec 31 14:58:36 2008 -0600
     3.2 +++ b/org.andrill.visualizer.core/META-INF/MANIFEST.MF	Fri Jan 02 10:40:41 2009 -0600
     3.3 @@ -4,7 +4,8 @@
     3.4  Bundle-SymbolicName: org.andrill.visualizer.core
     3.5  Bundle-Version: 1.0.0
     3.6  Bundle-Vendor: ANDRILL
     3.7 -Import-Package: org.osgi.framework;version="1.3.0",
     3.8 +Import-Package: javax.media.opengl,
     3.9 + org.osgi.framework;version="1.3.0",
    3.10   org.osgi.service.log;version="1.3.0",
    3.11   org.osgi.util.tracker;version="1.3.0"
    3.12  Bundle-Activator: org.andrill.visualizer.core.internal.Activator
     4.1 --- a/org.andrill.visualizer.core/build.properties	Wed Dec 31 14:58:36 2008 -0600
     4.2 +++ b/org.andrill.visualizer.core/build.properties	Fri Jan 02 10:40:41 2009 -0600
     4.3 @@ -1,4 +1,5 @@
     4.4  source.. = src/
     4.5  output.. = bin/
     4.6  bin.includes = META-INF/,\
     4.7 -               .
     4.8 \ No newline at end of file
     4.9 +               .
    4.10 +additional.bundles = jogl
     5.1 --- a/org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/Activator.java	Wed Dec 31 14:58:36 2008 -0600
     5.2 +++ b/org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/Activator.java	Fri Jan 02 10:40:41 2009 -0600
     5.3 @@ -5,7 +5,7 @@
     5.4  import org.andrill.visualizer.core.cache.IFileCache;
     5.5  import org.andrill.visualizer.core.internal.cache.FileCache;
     5.6  import org.andrill.visualizer.core.internal.job.JobService;
     5.7 -import org.andrill.visualizer.core.job.IJobService;
     5.8 +import org.andrill.visualizer.core.job.IJobs;
     5.9  import org.osgi.framework.BundleContext;
    5.10  import org.osgi.framework.ServiceRegistration;
    5.11  
    5.12 @@ -59,7 +59,7 @@
    5.13  
    5.14  		jobService = new JobService();
    5.15  		jobService.start();
    5.16 -		jobRegistration = context.registerService(IJobService.class.getName(),
    5.17 +		jobRegistration = context.registerService(IJobs.class.getName(),
    5.18  				jobService, null);
    5.19  	}
    5.20  
     6.1 --- a/org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/job/JobService.java	Wed Dec 31 14:58:36 2008 -0600
     6.2 +++ b/org.andrill.visualizer.core/src/org/andrill/visualizer/core/internal/job/JobService.java	Fri Jan 02 10:40:41 2009 -0600
     6.3 @@ -4,26 +4,27 @@
     6.4  import java.util.concurrent.ExecutorService;
     6.5  import java.util.concurrent.Executors;
     6.6  import java.util.concurrent.Future;
     6.7 -import java.util.concurrent.ScheduledExecutorService;
     6.8 -import java.util.concurrent.TimeUnit;
     6.9 +import java.util.concurrent.FutureTask;
    6.10  
    6.11 -import org.andrill.visualizer.core.job.IJobService;
    6.12 +import javax.media.opengl.Threading;
    6.13 +import javax.swing.SwingUtilities;
    6.14 +
    6.15 +import org.andrill.visualizer.core.job.IJobs;
    6.16  
    6.17  /**
    6.18   * An implementation of the IJobManager interface.
    6.19   * 
    6.20   * @author Josh Reed (jareed@andrill.org)
    6.21   */
    6.22 -public class JobService implements IJobService {
    6.23 +public class JobService implements IJobs {
    6.24  	private final ExecutorService cpuPool, ioPool;
    6.25 -	private final ScheduledExecutorService scheduledPool;
    6.26  
    6.27  	/**
    6.28  	 * Create a new JobManager.
    6.29  	 */
    6.30  	public JobService() {
    6.31 -		scheduledPool = Executors.newScheduledThreadPool(2);
    6.32 -		cpuPool = Executors.newFixedThreadPool(2);
    6.33 +		cpuPool = Executors.newFixedThreadPool(Runtime.getRuntime()
    6.34 +				.availableProcessors());
    6.35  		ioPool = Executors.newFixedThreadPool(4);
    6.36  	}
    6.37  
    6.38 @@ -40,38 +41,36 @@
    6.39  	public void stop() {
    6.40  		ioPool.shutdownNow();
    6.41  		cpuPool.shutdownNow();
    6.42 -		scheduledPool.shutdownNow();
    6.43  	}
    6.44  
    6.45  	/**
    6.46  	 * {@inheritDoc}
    6.47  	 */
    6.48 -	public <V> Future<V> submit(final Callable<V> task, final int pool) {
    6.49 -		switch (pool) {
    6.50 -		case CPU:
    6.51 +	public <V> Future<V> submit(final Callable<V> task, final Pool pool) {
    6.52 +		if (pool == Pool.CPU) {
    6.53  			return cpuPool.submit(task);
    6.54 -		case IO:
    6.55 +		} else if (pool == Pool.IO) {
    6.56  			return ioPool.submit(task);
    6.57 -		case SYSTEM:
    6.58 -			return scheduledPool.schedule(task, 0, TimeUnit.MILLISECONDS);
    6.59 -		default:
    6.60 -			return cpuPool.submit(task);
    6.61 +		} else if (pool == Pool.UI) {
    6.62 +			final FutureTask<V> future = new FutureTask<V>(task);
    6.63 +			SwingUtilities.invokeLater(future);
    6.64 +			return future;
    6.65 +		} else {
    6.66 +			if (Threading.isSingleThreaded()) {
    6.67 +				// is single threaded so either invoke it directly or submit it
    6.68 +				// to be run on the open GL thread
    6.69 +				final FutureTask<V> future = new FutureTask<V>(task);
    6.70 +				if (Threading.isOpenGLThread()) {
    6.71 +					future.run();
    6.72 +					return future;
    6.73 +				} else {
    6.74 +					Threading.invokeOnOpenGLThread(future);
    6.75 +					return future;
    6.76 +				}
    6.77 +			} else {
    6.78 +				// not single threaded so execute it in the CPU pool
    6.79 +				return cpuPool.submit(task);
    6.80 +			}
    6.81  		}
    6.82  	}
    6.83 -
    6.84 -	/**
    6.85 -	 * {@inheritDoc}
    6.86 -	 */
    6.87 -	public <V> Future<V> submitDelayed(final Callable<V> task, final long delay) {
    6.88 -		return scheduledPool.schedule(task, delay, TimeUnit.MILLISECONDS);
    6.89 -	}
    6.90 -
    6.91 -	/**
    6.92 -	 * {@inheritDoc}
    6.93 -	 */
    6.94 -	public Future<?> submitPeriodic(final Runnable task,
    6.95 -			final long initialDelay, final long period) {
    6.96 -		return scheduledPool.scheduleAtFixedRate(task, initialDelay, period,
    6.97 -				TimeUnit.MILLISECONDS);
    6.98 -	}
    6.99  }
     7.1 --- a/org.andrill.visualizer.core/src/org/andrill/visualizer/core/job/IJobService.java	Wed Dec 31 14:58:36 2008 -0600
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,56 +0,0 @@
     7.4 -package org.andrill.visualizer.core.job;
     7.5 -
     7.6 -import java.util.concurrent.Callable;
     7.7 -import java.util.concurrent.Future;
     7.8 -
     7.9 -/**
    7.10 - * Define the interface for a service that manages concurrently running jobs.
    7.11 - * 
    7.12 - * @author Josh Reed (jareed@andrill.org)
    7.13 - */
    7.14 -public interface IJobService {
    7.15 -	/** The CPU pool constant. */
    7.16 -	int CPU = 0;
    7.17 -
    7.18 -	/** The IO pool constant. */
    7.19 -	int IO = 1;
    7.20 -
    7.21 -	/** The System pool constant. */
    7.22 -	int SYSTEM = 2;
    7.23 -
    7.24 -	/**
    7.25 -	 * Submit a new Callable to the thread pool for immediate execution.
    7.26 -	 * 
    7.27 -	 * @param task
    7.28 -	 *            the Callable.
    7.29 -	 * @param pool
    7.30 -	 *            the pool to submit the job to.
    7.31 -	 * @return the Future for the job.
    7.32 -	 */
    7.33 -	<V> Future<V> submit(final Callable<V> task, int pool);
    7.34 -
    7.35 -	/**
    7.36 -	 * Submit a new Callable to the thread pool for delayed execution.
    7.37 -	 * 
    7.38 -	 * @param task
    7.39 -	 *            the Callable.
    7.40 -	 * @param delay
    7.41 -	 *            the delay in milliseconds.
    7.42 -	 * @return the Future for the job.
    7.43 -	 */
    7.44 -	<V> Future<V> submitDelayed(final Callable<V> task, final long delay);
    7.45 -
    7.46 -	/**
    7.47 -	 * Submit a new Runnable to the thread pool for periodic execution.
    7.48 -	 * 
    7.49 -	 * @param task
    7.50 -	 *            the task.
    7.51 -	 * @param initialDelay
    7.52 -	 *            the initial delay in milliseconds.
    7.53 -	 * @param period
    7.54 -	 *            the period between executions in milliseconds.
    7.55 -	 * @return the Future for the job.
    7.56 -	 */
    7.57 -	Future<?> submitPeriodic(final Runnable task, final long initialDelay,
    7.58 -			final long period);
    7.59 -}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/org.andrill.visualizer.core/src/org/andrill/visualizer/core/job/IJobs.java	Fri Jan 02 10:40:41 2009 -0600
     8.3 @@ -0,0 +1,29 @@
     8.4 +package org.andrill.visualizer.core.job;
     8.5 +
     8.6 +import java.util.concurrent.Callable;
     8.7 +import java.util.concurrent.Future;
     8.8 +
     8.9 +/**
    8.10 + * Define the interface for a service that manages concurrently running jobs.
    8.11 + * 
    8.12 + * @author Josh Reed (jareed@andrill.org)
    8.13 + */
    8.14 +public interface IJobs {
    8.15 +	/**
    8.16 +	 * Our thread pools.
    8.17 +	 */
    8.18 +	enum Pool {
    8.19 +		CPU, GL, IO, UI
    8.20 +	}
    8.21 +
    8.22 +	/**
    8.23 +	 * Submit a new Callable to the thread pool for immediate execution.
    8.24 +	 * 
    8.25 +	 * @param task
    8.26 +	 *            the Callable.
    8.27 +	 * @param pool
    8.28 +	 *            the pool to submit the job to.
    8.29 +	 * @return the Future for the job.
    8.30 +	 */
    8.31 +	<V> Future<V> submit(final Callable<V> task, Pool pool);
    8.32 +}
     9.1 --- a/org.andrill.visualizer.ui.image/src/org/andrill/visualizer/ui/image/ImageRenderable.java	Wed Dec 31 14:58:36 2008 -0600
     9.2 +++ b/org.andrill.visualizer.ui.image/src/org/andrill/visualizer/ui/image/ImageRenderable.java	Fri Jan 02 10:40:41 2009 -0600
     9.3 @@ -12,7 +12,8 @@
     9.4  import javax.media.opengl.GL;
     9.5  import javax.media.opengl.GLContext;
     9.6  
     9.7 -import org.andrill.visualizer.core.job.IJobService;
     9.8 +import org.andrill.visualizer.core.job.IJobs;
     9.9 +import org.andrill.visualizer.core.job.IJobs.Pool;
    9.10  import org.andrill.visualizer.ui.adapters.ILabelProvider;
    9.11  import org.andrill.visualizer.ui.camera.ICamera;
    9.12  import org.andrill.visualizer.ui.image.generator.ITileSetGenerator;
    9.13 @@ -71,8 +72,8 @@
    9.14  	@Override
    9.15  	public void enable() {
    9.16  		if (future == null) {
    9.17 -			future = (Activator.getDefault().getService(IJobService.class))
    9.18 -					.submit(generator, IJobService.IO);
    9.19 +			future = (Activator.getDefault().getService(IJobs.class))
    9.20 +					.submit(generator, Pool.IO);
    9.21  		}
    9.22  	}
    9.23  
    10.1 --- a/org.andrill.visualizer.ui/src/org/andrill/visualizer/ui/internal/camera/GLTile.java	Wed Dec 31 14:58:36 2008 -0600
    10.2 +++ b/org.andrill.visualizer.ui/src/org/andrill/visualizer/ui/internal/camera/GLTile.java	Fri Jan 02 10:40:41 2009 -0600
    10.3 @@ -17,6 +17,7 @@
    10.4  import javax.media.opengl.GLEventListener;
    10.5  import javax.swing.JFrame;
    10.6  
    10.7 +import org.andrill.visualizer.core.Timer;
    10.8  import org.andrill.visualizer.ui.internal.Activator;
    10.9  import org.andrill.visualizer.ui.renderable.IRenderable;
   10.10  
   10.11 @@ -84,11 +85,11 @@
   10.12  
   10.13  		// find all renderables in view
   10.14  		for (final IRenderable r : renderables) {
   10.15 +			if (!r.isValid()) {
   10.16 +				r.validate();
   10.17 +			}
   10.18  			if (r.isLayer() || r.getBounds().intersects(world)) {
   10.19  				// validate if necessary
   10.20 -				if (!r.isValid()) {
   10.21 -					r.validate();
   10.22 -				}
   10.23  				repaint.add(r);
   10.24  			}
   10.25  		}
   10.26 @@ -132,12 +133,15 @@
   10.27  			gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
   10.28  
   10.29  			// render our renderables
   10.30 +			Timer.start();
   10.31  			final GLContext context = drawable.getContext();
   10.32  			gl.glPushAttrib(GL.GL_ALL_ATTRIB_BITS);
   10.33  			for (final IRenderable renderable : cull()) {
   10.34 +				System.out.println("Rendering " + renderable);
   10.35  				renderable.render(context);
   10.36  			}
   10.37  			gl.glPopAttrib();
   10.38 +			Timer.elapsed("Rendering");
   10.39  
   10.40  			// flush the pipeline
   10.41  			gl.glFlush();