Re: adding shapes to a display

On Mon, 26 May 2003, maohai huang wrote:

> I understand that the way to add shapes to a 2D
> display is demonstrated in Test46 and described in
> If all I want to do is using one shape to plot all points
> in a 2D plot, and have the option to change in shape
> at runtime, do I have to to make something like
> time -> (height, shape) or index->(t, h, shape)
> then map shape to Display.Shape? I tried to pass a
> dataReference to a one cell Gridded1DSet, and add
> this dataReference to the display:
> ...
>  RealType shape_index = RealType.getRealType("shape_index");
>  shapeMap = new ScalarMap(shape_index, Display.Shape);
> display.addMap(shapeMap);
> Gridded1DSet shape = new Gridded1DSet(shape_index,new float[][]{{1f}},1);
> DataReference shape_ref = new DataReferenceImpl("the_shape");
> shape_ref.setData(shape);
> display.addReference(shape_ref, null);
> ShapeControl scontrol = (ShapeControl) shapeMap.getControl();
> ... setShapeSet and setShapes etc.
> But it doesn't work.

In what way doesn't it work? I would expect a Set with one
member to plot as a single shape.

> Looks like I have to make a
> function type, a flatfield, and add a reference to
> that flatfield to the display. It seems there is
> no way to add one shape to all data point
> in a way as simple as changing the color using a
> constantMap. Is this correct.

I have never tried using a ConstantMap to Shape, and doubt
it would work.

If you want to change shapes at runtime, you can do it
with calls to setShapes().

> Complexity of the code aside, I wonder, for
>  example,  if I add shapes as time->(height, shape),
> will visad create arrays of the same size of time
> for shape just to hold one bite of information
> as which shape to use? time could have many
> points (to the order of 1 million for what i am doing now).

There may be a temporary array of shape indices, but it
will much smaller than the array of shapes themselves
passed to Java3D or Java2D. 1 million VisADGeometryArrays
will use lots of memory, depending on the complexity of
the shapes. Since you cannot plot all 1 million shapes at
once, you might experiment with a more interactive approach
where fewer shapes are computed and displayed as needed.

> One last question, when I add shapes to
> time->height, the lines connecting the points
> disappears. How can get the lines back but
> still keep the shapes.

For this, you need a second Data object with the same
values but different RealTypes, and excluding any RealType
mapped to Shape. The first Data will be depicted as shapes,
the second as connecting lines.

Good luck,

  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: