Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Added a new ConnectionPlotRender as a sub-class of PlotRender and a
Browse files Browse the repository at this point in the history
parent class of ParaViewPlotRender. It performs error handling for
IConnectionAdapters and only sends requests to render to the sub-class
if the connection is valid.

Made the icon in the PlotRender's infoComposite customizable by
sub-classes.

Converted the ConnectionPlot to be a sub-class of MultiPlot and a parent
class of ParaViewPlot.

Signed-off-by: Jordan <jordan.deyton@gmail.com>
  • Loading branch information
jdeyton committed Mar 5, 2015
1 parent bb2d8bb commit e8c2598
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 520 deletions.
Expand Up @@ -14,13 +14,13 @@
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.eclipse.ice.viz.service.MultiPlot;
import org.eclipse.ice.viz.service.PlotRender;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ice.viz.service.connections.ConnectionPlot;
import org.eclipse.swt.widgets.Composite;

import com.kitware.vtk.web.VtkWebClient;

/**
* This class is responsible for embedding ParaView-supported graphics inside
* client {@link Composite}s.
Expand All @@ -34,7 +34,7 @@
* @author Jordan Deyton
*
*/
public class ParaViewPlot extends MultiPlot {
public class ParaViewPlot extends ConnectionPlot<VtkWebClient> {

/**
* The default constructor.
Expand All @@ -55,6 +55,7 @@ public ParaViewPlot(ParaViewVizService vizService, URI file) {
*/
@Override
public Map<String, String[]> getPlotTypes() throws Exception {
// TODO
return new HashMap<String, String[]>();
}

Expand Down Expand Up @@ -83,17 +84,4 @@ protected void updatePlotRender(PlotRender plotRender) {
super.updatePlotRender(plotRender);
}

// /*
// * (non-Javadoc)
// *
// * @see
// *
// org.eclipse.ice.viz.service.connections.ConnectionPlot#getPreferenceNodeID
// * ()
// */
// @Override
// protected String getPreferenceNodeID() {
// return "org.eclipse.ice.viz.service.paraview.preferences";
// }

}
Expand Up @@ -2,37 +2,81 @@

import java.util.Random;

import org.eclipse.ice.viz.service.PlotRender;
import org.eclipse.ice.viz.service.connections.ConnectionPlotRender;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;

public class ParaViewPlotRender extends PlotRender {
import com.kitware.vtk.web.VtkWebClient;

public class ParaViewPlotRender extends ConnectionPlotRender<VtkWebClient> {

/**
* The default constructor.
*
* @param parent
* The parent Composite that contains the plot render.
*
* @param plot
* The rendered ConnectionPlot. This cannot be changed.
*/
public ParaViewPlotRender(Composite parent, ParaViewPlot plot) {
super(parent, plot);

}

/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender#
* createPlotComposite(org.eclipse.swt.widgets.Composite, int,
* java.lang.Object)
*/
@Override
protected Composite createPlotComposite(Composite parent, int style)
throws Exception {
// TODO Hook this up to the ParaView widgets.
protected Composite createPlotComposite(Composite parent, int style,
VtkWebClient connection) throws Exception {
return new Composite(parent, style);
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender#
* updatePlotComposite(org.eclipse.swt.widgets.Composite, java.lang.Object)
*/
@Override
protected void updatePlotComposite(Composite plotComposite)
throws Exception {
protected void updatePlotComposite(Composite plotComposite,
VtkWebClient connection) throws Exception {

// TODO Hook this up to the ParaView widgets.
int seed = (getPlotCategory() + getPlotType()).hashCode();
Random r = new Random(seed);
plotComposite.setBackground(new Color(plotComposite.getDisplay(), r
.nextInt(255), r.nextInt(255), r.nextInt(255)));

return;
}

/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.viz.service.PlotRender#disposePlotComposite(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected void disposePlotComposite(Composite plotComposite) {
// Nothing to do yet.
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ice.viz.service.connections.ConnectionPlotRender#
* getPreferenceNodeID()
*/
@Override
protected String getPreferenceNodeID() {
return "org.eclipse.ice.viz.service.paraview.preferences";
}

}
@@ -1,7 +1,9 @@
package org.eclipse.ice.viz.service;

import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.ice.client.widgets.viz.service.IPlot;
Expand Down Expand Up @@ -206,7 +208,7 @@ protected void setDataSource(URI file) {
*
* @return The visualization service responsible for this plot.
*/
protected IVizService getVizService() {
public IVizService getVizService() {
return vizService;
}

Expand All @@ -233,6 +235,16 @@ protected IVizService getVizService() {
protected void updatePlotRender(PlotRender plotRender) {
plotRender.refresh();
}

/**
* Gets a list of all current rendered plots.
*
* @return A list containing each current {@link PlotRender} in this
* {@code MultiPlot}.
*/
protected List<PlotRender> getPlotRenders() {
return new ArrayList<PlotRender>(plotRenders.values());
}
// -------------------- //

}
Expand Up @@ -74,6 +74,11 @@ public abstract class PlotRender {
*/
private Label msgLabel;

/**
* The image to display in the {@link #iconLabel}.
*/
protected Image infoIcon;

// -------------------- //

/**
Expand Down Expand Up @@ -152,7 +157,7 @@ public String getPlotType() {
* update to the UI on the display's UI thread.
* </p>
*/
protected void refresh() {
public void refresh() {

// If we are not on the UI thread, update the UI asynchronously on
// the UI thread.
Expand Down Expand Up @@ -305,16 +310,19 @@ protected Composite createInfoComposite(Composite parent, int style) {
protected void updateInfoComposite(Composite infoComposite,
final String message) {
// Set the message and icon based on the state of the connection.
final Image image;
final Display display = infoComposite.getDisplay();

// Set a default image.
image = display.getSystemImage(SWT.ICON_WARNING);
// If there's no icon set, default to something useful.
final Image image = (infoIcon != null ? infoIcon : display
.getSystemImage(SWT.ICON_WARNING));

// Update the contents of the infoComposite's widgets.
iconLabel.setImage(image);
msgLabel.setText(message);

// Force the StackLayout to refresh. We need the two boolean flags so
// that the text will wrap properly.
stackComposite.layout(true, true);

return;
}

Expand Down

0 comments on commit e8c2598

Please sign in to comment.