Commit 99c642f2 authored by Robert Smith's avatar Robert Smith
Browse files

EAVP design improvements



Made various enhancements to the EAVP packages' design, including the
creation of a Representation wrapper class for IView's graphics
program-specific data objects and the addition of a method for the
programmer to specify the expected return type when getting an
IController's entities.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent d10d733f
......@@ -8,3 +8,4 @@
/GeometryEditorTutorial.aux
/GeometryEditorTutorial.log
/GeometryEditorTutorial.out
/geometryEditorTutoria.synctex.gz
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.eclipse.eavp.feature"
label="Eclipse Advanced Visualization Project Feature"
version="2.1.8.20160208"
provider-name="Oak Ridge National Laboratory">
<description url="https://www.eclipse.org/eavp">
Eclipse Advanced Visualization Project Feature
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="org.eclipse.eavp.viz.service"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.geometry"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx.geometry"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx.mesh"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.mesh"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.paraview"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.paraview.web"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.eclipse.eavp.feature"
label="Eclipse Advanced Visualization Project Feature"
version="2.1.8.20160208"
provider-name="Oak Ridge National Laboratory">
<description url="https://www.eclipse.org/eavp">
Eclipse Advanced Visualization Project Feature
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="org.eclipse.eavp.viz.service"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.geometry"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx.geometry"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.javafx.mesh"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.mesh"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.paraview"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.paraview.web"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="gov.lbnl.visit.swt"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.eavp.viz.service.visit"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
......@@ -83,10 +83,10 @@ public class PipeControllerTester {
// Add an input and output, as well as another pipe
AbstractController input = new AbstractController(new AbstractMesh(),
new AbstractView());
pipe.addEntityByCategory(input, ReactorMeshCategory.INPUT);
pipe.addEntityToCategory(input, ReactorMeshCategory.INPUT);
AbstractController output = new AbstractController(new AbstractMesh(),
new AbstractView());
pipe.addEntityByCategory(output, ReactorMeshCategory.OUTPUT);
pipe.addEntityToCategory(output, ReactorMeshCategory.OUTPUT);
PipeController child = new PipeController(new PipeMesh(),
new AbstractView());
pipe.addEntity(child);
......
......@@ -43,10 +43,10 @@ public class ReactorControllerTester {
new AbstractView());
// Add the pipe as a core channel
reactor.addEntityByCategory(pipe, ReactorMeshCategory.CORE_CHANNELS);
reactor.addEntityToCategory(pipe, ReactorMeshCategory.CORE_CHANNELS);
// Check that the pipe has the reactor as a parent
assertTrue(pipe.getEntitiesByCategory(MeshCategory.PARENT)
assertTrue(pipe.getEntitiesFromCategory(MeshCategory.PARENT)
.get(0) == reactor);
}
}
......@@ -43,10 +43,10 @@ public class ReactorMeshTester {
new AbstractView());
// Add the pipe as a core channel
reactor.addEntityByCategory(pipe, ReactorMeshCategory.CORE_CHANNELS);
reactor.addEntityToCategory(pipe, ReactorMeshCategory.CORE_CHANNELS);
// Check that the pipe has the reactor as a parent
assertTrue(pipe.getEntitiesByCategory(MeshCategory.PARENT)
assertTrue(pipe.getEntitiesFromCategory(MeshCategory.PARENT)
.get(0) == reactor);
}
}
......@@ -12,7 +12,7 @@ package org.eclipse.eavp.viz.service.geometry.reactor;
import org.eclipse.eavp.viz.service.modeling.AbstractController;
import org.eclipse.eavp.viz.service.modeling.AbstractView;
import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
import org.eclipse.eavp.viz.service.modeling.IWireframeController;
/**
* The internal data representation for a Heat Exchanger part.
......@@ -21,7 +21,7 @@ import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
*
*/
public class HeatExchangerController extends AbstractController
implements IWireFramePart {
implements IWireframeController {
/**
* The nullary constructor.
......@@ -111,7 +111,7 @@ public class HeatExchangerController extends AbstractController
*/
@Override
public void setWireFrameMode(boolean on) {
((IWireFramePart) view).setWireFrameMode(on);
((IWireframeController) view).setWireFrameMode(on);
}
}
......@@ -41,7 +41,7 @@ public class HeatExchangerMesh extends AbstractMesh {
*/
public PipeController getPrimaryPipe() {
List<IController> category = getEntitiesByCategory(
List<IController> category = getEntitiesFromCategory(
ReactorMeshCategory.PRIMARY_PIPE);
return !category.isEmpty() ? (PipeController) category.get(0) : null;
......@@ -54,7 +54,7 @@ public class HeatExchangerMesh extends AbstractMesh {
* one.
*/
public PipeController getSecondaryPipe() {
List<IController> category = getEntitiesByCategory(
List<IController> category = getEntitiesFromCategory(
ReactorMeshCategory.SECONDARY_PIPE);
return !category.isEmpty() ? (PipeController) category.get(0) : null;
......@@ -85,7 +85,7 @@ public class HeatExchangerMesh extends AbstractMesh {
}
// Add the pipe under the Primary Pipe category
addEntityByCategory(pipe, ReactorMeshCategory.PRIMARY_PIPE);
addEntityToCategory(pipe, ReactorMeshCategory.PRIMARY_PIPE);
}
/**
......@@ -109,7 +109,7 @@ public class HeatExchangerMesh extends AbstractMesh {
}
// Add the pipe under the Primary Pipe category
addEntityByCategory(pipe, ReactorMeshCategory.SECONDARY_PIPE);
addEntityToCategory(pipe, ReactorMeshCategory.SECONDARY_PIPE);
}
/*
......@@ -121,7 +121,7 @@ public class HeatExchangerMesh extends AbstractMesh {
* java.lang.String)
*/
@Override
public void addEntityByCategory(IController newEntity,
public void addEntityToCategory(IController newEntity,
IMeshCategory category) {
// Don't listen to junctions, to avoid circular listening
......@@ -161,7 +161,7 @@ public class HeatExchangerMesh extends AbstractMesh {
// Otherwise, add the entity normally
else {
super.addEntityByCategory(newEntity, category);
super.addEntityToCategory(newEntity, category);
}
}
......
......@@ -12,7 +12,7 @@ package org.eclipse.eavp.viz.service.geometry.reactor;
import org.eclipse.eavp.viz.service.modeling.AbstractController;
import org.eclipse.eavp.viz.service.modeling.AbstractView;
import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
import org.eclipse.eavp.viz.service.modeling.IWireframeController;
/**
* A Junction part for the Reactor Analyzer.
......@@ -21,7 +21,7 @@ import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
*
*/
public class JunctionController extends AbstractController
implements IWireFramePart {
implements IWireframeController {
/**
* The nullary constructor
......@@ -58,7 +58,7 @@ public class JunctionController extends AbstractController
*/
@Override
public void setWireFrameMode(boolean on) {
((IWireFramePart) view).setWireFrameMode(on);
((IWireframeController) view).setWireFrameMode(on);
}
/*
......
......@@ -13,7 +13,7 @@ package org.eclipse.eavp.viz.service.geometry.reactor;
import org.eclipse.eavp.viz.service.modeling.AbstractController;
import org.eclipse.eavp.viz.service.modeling.AbstractView;
import org.eclipse.eavp.viz.service.modeling.IController;
import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
import org.eclipse.eavp.viz.service.modeling.IWireframeController;
import org.eclipse.eavp.viz.service.modeling.TubeController;
/**
......@@ -22,7 +22,7 @@ import org.eclipse.eavp.viz.service.modeling.TubeController;
* @author Robert Smith
*
*/
public class PipeController extends TubeController implements IWireFramePart {
public class PipeController extends TubeController implements IWireframeController {
/**
* The nullary constructor.
......@@ -138,7 +138,7 @@ public class PipeController extends TubeController implements IWireFramePart {
*/
@Override
public void setWireFrameMode(boolean on) {
((IWireFramePart) view).setWireFrameMode(on);
((IWireframeController) view).setWireFrameMode(on);
}
/*
......
......@@ -122,7 +122,7 @@ public class PipeMesh extends TubeMesh {
* eclipse.ice.viz.service.modeling.AbstractController, java.lang.String)
*/
@Override
public void addEntityByCategory(IController entity,
public void addEntityToCategory(IController entity,
IMeshCategory category) {
// If adding an input or output, add it without registering
......@@ -163,7 +163,7 @@ public class PipeMesh extends TubeMesh {
// Otherwise, add it normally
else {
super.addEntityByCategory(entity, category);
super.addEntityToCategory(entity, category);
}
}
......
......@@ -12,7 +12,7 @@ package org.eclipse.eavp.viz.service.geometry.reactor;
import org.eclipse.eavp.viz.service.modeling.AbstractController;
import org.eclipse.eavp.viz.service.modeling.AbstractView;
import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
import org.eclipse.eavp.viz.service.modeling.IWireframeController;
/**
* A reactor part for a Reactor Analyzer. Reactors represent a container around
......@@ -23,7 +23,7 @@ import org.eclipse.eavp.viz.service.modeling.IWireFramePart;
*
*/
public class ReactorController extends AbstractController
implements IWireFramePart {
implements IWireframeController {
/**
* The nullary constructor.
......@@ -52,6 +52,6 @@ public class ReactorController extends AbstractController
*/
@Override
public void setWireFrameMode(boolean on) {
((IWireFramePart) view).setWireFrameMode(on);
((IWireframeController) view).setWireFrameMode(on);
}
}
......@@ -38,7 +38,7 @@ public class ReactorMesh extends ShapeMesh {
* java.lang.String)
*/
@Override
public void addEntityByCategory(IController entity,
public void addEntityToCategory(IController entity,
IMeshCategory category) {
// If the entity is a Core Channel, set this shape as its parent, so
......@@ -48,7 +48,7 @@ public class ReactorMesh extends ShapeMesh {
((PipeController) entity).setParent(controller);
}
super.addEntityByCategory(entity, category);
super.addEntityToCategory(entity, category);
}
}
......@@ -223,7 +223,7 @@ public class ActionAddShape extends Action {
ShapeController selectedShape = (ShapeController) selectedObject;
parentComplexShape = selectedShape
.getEntitiesByCategory(MeshCategory.PARENT).get(0);
.getEntitiesFromCategory(MeshCategory.PARENT).get(0);
} else if (selectedObject instanceof BlankShape) {
// Get the selected blank shape's parent
......
......@@ -115,7 +115,7 @@ public class ActionDeleteShape extends Action {
ShapeController selectedShape = (ShapeController) selectedObject;
ShapeController parentShape = (ShapeController) selectedShape
.getEntitiesByCategory(MeshCategory.PARENT).get(0);
.getEntitiesFromCategory(MeshCategory.PARENT).get(0);
if (parentShape instanceof ShapeController) {
......
......@@ -106,7 +106,7 @@ public class ActionDuplicateShape extends Action {
// We can assume that if the parent exists, it is a ComplexShape
ShapeController parentShape = (ShapeController) selectedShape
.getEntitiesByCategory(MeshCategory.PARENT).get(0);
.getEntitiesFromCategory(MeshCategory.PARENT).get(0);
if (parentShape != null) {
......@@ -114,7 +114,7 @@ public class ActionDuplicateShape extends Action {
// siblings
List<IController> childShapes = parentShape
.getEntitiesByCategory(MeshCategory.CHILDREN);
.getEntitiesFromCategory(MeshCategory.CHILDREN);
int selectedShapeIndex = childShapes.indexOf(selectedShape);
if (selectedShapeIndex < 0) {
......@@ -133,7 +133,7 @@ public class ActionDuplicateShape extends Action {
// siblings
List<IController> childShapes = geometry
.getEntitiesByCategory(MeshCategory.CHILDREN);
.getEntitiesFromCategory(MeshCategory.CHILDREN);
int selectedShapeIndex = childShapes.indexOf(selectedShape);
// Add the cloned shape to the root GeometryComponent
......
......@@ -154,7 +154,7 @@ public class ActionReplicateShape extends Action {
// its parent shape is null.
ShapeController parentShape = (ShapeController) selectedShape
.getEntitiesByCategory(MeshCategory.PARENT).get(0);
.getEntitiesFromCategory(MeshCategory.PARENT).get(0);
// Remove the selected shape from its original parent
......
......@@ -73,11 +73,10 @@ public class ShapeTreeContentProvider implements ITreeContentProvider {
if (parentShape.getProperty(GeometryMeshProperty.OPERATOR) != null) {
// IShape is a ComplexShape, so put its children in the
// temporary
// children field
// temporary children field
temporaryChildren = parentShape
.getEntitiesByCategory(MeshCategory.CHILDREN).toArray();
.getEntitiesFromCategory(MeshCategory.CHILDREN).toArray();
// Use a blank state if there are no children to display
......@@ -124,7 +123,7 @@ public class ShapeTreeContentProvider implements ITreeContentProvider {
if (inputElement instanceof AbstractController) {
// Return an array of the GeometryComponent's shapes
IController parentGeometry = (IController) inputElement;
return parentGeometry.getEntitiesByCategory(MeshCategory.CHILDREN)
return parentGeometry.getEntitiesFromCategory(MeshCategory.CHILDREN)
.toArray();
} else {
return null;
......@@ -157,7 +156,7 @@ public class ShapeTreeContentProvider implements ITreeContentProvider {
// Return the object's parent
ShapeController shape = (ShapeController) element;
return shape.getEntitiesByCategory(MeshCategory.PARENT);
return shape.getEntitiesFromCategory(MeshCategory.PARENT);
}
......
......@@ -19,9 +19,10 @@ import org.eclipse.eavp.viz.service.javafx.geometry.datatypes.FXShapeView;
import org.eclipse.eavp.viz.service.modeling.AbstractController;
import org.eclipse.eavp.viz.service.modeling.AbstractMesh;
import org.eclipse.eavp.viz.service.modeling.AbstractView;
import org.eclipse.eavp.viz.service.modeling.MeshCategory;
import org.eclipse.eavp.viz.service.modeling.IMesh;
import org.eclipse.eavp.viz.service.modeling.MeshCategory;
import org.eclipse.eavp.viz.service.modeling.MeshProperty;
import org.eclipse.eavp.viz.service.modeling.Representation;
import org.eclipse.eavp.viz.service.modeling.ShapeController;
import org.eclipse.eavp.viz.service.modeling.ShapeMesh;
import org.eclipse.eavp.viz.service.modeling.Transformation;
......@@ -69,7 +70,8 @@ public class FXShapeControllerTester {
FXShapeController shape = new FXShapeController(mesh, view);
// The JavaFX node should have a reference to the FXShapeController
assertTrue(shape == ((Group) shape.getRepresentation()).getProperties()
Representation<Group> representation = shape.getRepresentation();
assertTrue(shape == representation.getData().getProperties()
.get(ShapeController.class));
// Create a sphere
......@@ -81,8 +83,10 @@ public class FXShapeControllerTester {
// Add the sphere shape as a child to the cube shape. The cube JavaFX
// node should now have the sphere JavaFX node as a child
shape.addEntity(shape2);
assertTrue(((Group) shape.getRepresentation()).getChildren()
.contains(shape2.getRepresentation()));
representation = shape.getRepresentation();
Representation<Group> representation2 = shape2.getRepresentation();
assertTrue(representation.getData().getChildren()
.contains(representation2.getData()));
// Create a cylinder
ShapeMesh mesh3 = new ShapeMesh();
......@@ -93,22 +97,28 @@ public class FXShapeControllerTester {
// Add the cylinder shape as a child to the cube shape. The cube JavaFX
// node should now have both JavaFX nodes as children.
shape.addEntity(shape3);
assertTrue(((Group) shape.getRepresentation()).getChildren()
.contains(shape2.getRepresentation()));
assertTrue(((Group) shape.getRepresentation()).getChildren()
.contains(shape3.getRepresentation()));
representation = shape.getRepresentation();
Representation<Group> representation3 = shape3.getRepresentation();
assertTrue(representation.getData().getChildren()
.contains(representation2.getData()));
assertTrue(representation.getData().getChildren()
.contains(representation3.getData()));
// Remove the cube from being the sphere's parent. This should remove
// its JavaFX node from the cube's JavaFX node's children.
shape2.removeEntity(shape);
assertFalse(((Group) shape.getRepresentation()).getChildren()
.contains(shape2.getRepresentation()));
representation = shape.getRepresentation();
representation2 = shape2.getRepresentation();
assertFalse(representation.getData().getChildren()
.contains(representation2.getData()));
// Remove the cylinder from the sphere's children. This should also
// remove its JavaFX node from the cube's JavaFX node's children
shape.removeEntity(shape3);
assertFalse(((Group) shape.getRepresentation()).getChildren()
.contains(shape3.getRepresentation()));
representation = shape.getRepresentation();
representation3 = shape3.getRepresentation();