public class BallAndStickFactory extends Object
IndexedLineSet
and returns
it in the form of an instance of SceneGraphComponent
.
In the default behavior, around each edge (vertex) of the IndexedLineSet is placed a cylinder (sphere). The radius can be separately controlled for the cylinders and for the spheres, as can the colors. Additionally, one can specify that arrow symbols be positioned along the tubes; here one can control the relative position, the size, and the steepness of the arrow head (which is essentially a cone).
The cross section of the tube is currently fixed to be an octagon. The returned SceneGraphComponent has two children, containing the sticks and the balls, respectively.
The general cycle of use is illustrated in the following code snippet:
BallAndStickFactory basf = new BallAndStickFactory(Primitives.sharedIcosahedron);
basf.setBallRadius(.04);
basf.setStickRadius(.02);
basf.setDrawArrows(true);
basf.setArrowScale(.1);
basf.setArrowSlope(1.5);
basf.setArrowPosition(.9);
basf.update();
SceneGraphComponent tubedIcosa = basf.getSceneGraphComponent();
Note: The same effect (without the arrows) can be achieved
with the standard line and point shaders (DefaultLineShader
, etc),
by setting CommonAttributes.TUBES_DRAW
and CommonAttributes.SPHERES_DRAW
,
resp., to true
and setting the other shader parameters to control the
color and radius of the rusulting tubes and spheres. However, there are some constraints on this;
for example, it isn't possible to turn on flat shading and separate control of the
transparency is not possible.
TubeUtility.tubeOneEdge(double[], double[], double, double[][], int)
Constructor and Description |
---|
BallAndStickFactory(IndexedLineSet i) |
Modifier and Type | Method and Description |
---|---|
double |
getArrowPosition() |
double |
getArrowScale() |
double |
getArrowSlope() |
Geometry |
getBallGeometry() |
double[][] |
getCrossSection() |
SceneGraphComponent |
getSceneGraphComponent() |
Geometry |
getStickGeometry() |
boolean |
isShowArrows() |
boolean |
isShowBalls() |
boolean |
isShowSticks() |
void |
setArrowColor(Color arrowColor) |
void |
setArrowPosition(double arrowPosition) |
void |
setArrowScale(double arrowScale) |
void |
setArrowSlope(double arrowSlope) |
void |
setBallColor(Color ballColor) |
void |
setBallGeometry(Geometry ballGeometry) |
void |
setBallRadius(double ballRadius) |
void |
setCrossSection(double[][] crossSection) |
void |
setMetric(int metric) |
void |
setShowArrows(boolean drawArrows) |
void |
setShowBalls(boolean showBalls) |
void |
setShowSticks(boolean showSticks) |
void |
setStickColor(Color stickColor) |
void |
setStickGeometry(Geometry stickGeometry) |
void |
setStickRadius(double r) |
static SceneGraphComponent |
sticks(SceneGraphComponent sgc,
IndexedLineSet ifs,
double rad,
int metric) |
void |
update() |
public BallAndStickFactory(IndexedLineSet i)
public void update()
public void setStickRadius(double r)
public void setBallColor(Color ballColor)
public void setBallRadius(double ballRadius)
public void setStickColor(Color stickColor)
public void setArrowColor(Color arrowColor)
public void setMetric(int metric)
public SceneGraphComponent getSceneGraphComponent()
public static SceneGraphComponent sticks(SceneGraphComponent sgc, IndexedLineSet ifs, double rad, int metric)
public double getArrowPosition()
public void setArrowPosition(double arrowPosition)
public double getArrowScale()
public void setArrowScale(double arrowScale)
public double getArrowSlope()
public void setArrowSlope(double arrowSlope)
public boolean isShowArrows()
public void setShowArrows(boolean drawArrows)
public boolean isShowBalls()
public void setShowBalls(boolean showBalls)
public boolean isShowSticks()
public void setShowSticks(boolean showSticks)
public double[][] getCrossSection()
public void setCrossSection(double[][] crossSection)
public Geometry getBallGeometry()
public void setBallGeometry(Geometry ballGeometry)
public Geometry getStickGeometry()
public void setStickGeometry(Geometry stickGeometry)