//
// ShapeControl.java
//

/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad;

import java.rmi.*;

import visad.util.Util;

/**
   ShapeControl is the VisAD class for controlling Shape display scalars.

*/ public class ShapeControl extends Control { private SimpleSet shapeSet = null; private VisADGeometryArray[] shapes = null; // WLH 31 May 2000 private float scale = 1.0f; // WLH 6 Aug 2001 private boolean autoScale = false; private ProjectionControlListener pcl = null; public ShapeControl(DisplayImpl d) { super(d); } /** * Sets the SimpleSet that defines the mapping from RealType values to indices * into an array of shapes. This method must be called before the * setShapes() method to avoid a subsequent NullPointerException in the * running of the display. * * @param set 1-D set of values that defines the mapping from * RealType values to indices into the array of * shapes. The domain dimension shall be 1. */ public synchronized void setShapeSet(SimpleSet set) throws VisADException, RemoteException { if (set == null) { shapeSet = null; shapes = null; return; } if (set.getDimension() != 1) { throw new DisplayException("ShapeControl.setShapeSet: domain " + "dimension must be 1"); } shapeSet = set; shapes = new VisADGeometryArray[shapeSet.getLength()]; changeControl(true); } /** set the shape associated with index; the VisADGeometryArray class hierarchy defines various kinds of shapes */ public synchronized void setShape(int index, VisADGeometryArray shape) throws VisADException, RemoteException { if (shapes == null) return; if (0 <= index && index < shapes.length) { shapes[index] = shape; } changeControl(true); } /** * Sets the array of shapes. The array is accessed by index determined from * the value-to-index mapping established by the setShapeSet() * method. The VisADGeometryArray class hierarchy defines various kinds of * shapes. This method must be called after the setShapeSet() * method to avoid a subsequent NullPointerException in the running of the * display. * * @param shs The array of shapes. */ public synchronized void setShapes(VisADGeometryArray[] shs) throws VisADException, RemoteException { if (shapeSet == null) return; if (shs != null && shs.length > 0) { final int len = Math.min(shs.length, shapes.length); for (int i=0; i shs.length) { for (int i=shs.length; i < shapes.length; i++) { shapes[i] = null; } } } changeControl(true); } public synchronized VisADGeometryArray[] getShapes(float[] values) throws VisADException { if (values == null || values.length < 1) return null; VisADGeometryArray[] sh = new VisADGeometryArray[values.length]; if (shapeSet == null) return sh; float[][] set_values = new float[1][]; set_values[0] = values; int[] indices = null; if (shapeSet.getLength() < 2) { indices = new int[values.length]; for (int i=0; i

Ads help maintain this website.