//
// DataDisplayLink.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.util.*;
import java.rmi.*;
/**
DataDisplayLink objects define connections between DataReference
objects and Display objects. It extends ReferenceActionLink which
is the more general link between ThingReference (extended by
DataReference) and Action (extended by Display).
*/
public class DataDisplayLink extends ReferenceActionLink {
/** ShadowType created for data */
private ShadowType shadow;
/** cached copy of linked Data, used by prepareData() */
private Data data;
/** ConstantMaps specific to this Data */
private Vector ConstantMapVector = new Vector();
/** DataRenderer associated with this Data
(may be multiple Data per DataRenderer) */
private DataRenderer renderer;
/** Vector of ScalarMaps applying to this Data */
private Vector SelectedMapVector = new Vector();
/** default values for DisplayRealTypes, determined by:
1. this.ConstantMapVector
2. Display.ConstantMapVector
3. DisplayRealType.DefaultValue */
private float[] defaultValues;
/** flag per Control to indicate need for transform when
Control changes, index by Control.getIndex() */
boolean[] isTransform;
/** value of System.currentTimeMillis() when doTransform() started */
public long start_time;
/** flag indicating current doTransform() has taken more than 500 ms */
public boolean time_flag;
/**
* construct a DataDisplayLink linking a DataReference to a Display
* @param ref the DataReference to link
* @param local_d if d is DisplayImpl, then d; if d is RemoteDisplay, then
* its adapted DisplayImpl
* @param d the Display
* @param constant_maps array of ConstantMaps specific to this Data
* @param rend DataRenderer that creates Data depictions
* @param jd - unique ID among ReferenceActionLinks attached to Action
* @throws VisADException a VisAD error occurred
* @throws RemoteException an RMI error occurred
*/
public DataDisplayLink(DataReference ref, DisplayImpl local_d, Display d,
ConstantMap[] constant_maps, DataRenderer rend, long jd)
throws VisADException, RemoteException {
super(ref, local_d, d, jd);
renderer = rend;
setConstantMaps(constant_maps, true);
}
/**
* Change ConstantMaps[] array specific to this DataDisplayLink
* Note this call should occur between
* display.disableAction()
* and
* display.enableAction()
*
* there are two ways for an application to get a DataDisplayLink:
* given a DisplayImpl and a DataReference:
* DataDisplayLink link = (DataDisplayLink) display.findReference(ref);
* given a DataRenderer (assuming it has only one DataReference):
* DataDisplayLink link = renderer.getLinks()[0];
*
* @param constant_maps array of ConstantMaps specific to this Data
* @throws VisADException a VisAD error occurred
* @throws RemoteException an RMI error occurred
*/
public void setConstantMaps(ConstantMap[] constant_maps)
throws VisADException, RemoteException {
setConstantMaps(constant_maps, false);
}
private void setConstantMaps(ConstantMap[] constant_maps, boolean init)
throws VisADException, RemoteException {
Enumeration maps;
synchronized (ConstantMapVector) {
if (!init) {
maps = ConstantMapVector.elements();
while(maps.hasMoreElements()) {
ConstantMap map = (ConstantMap) maps.nextElement();
map.nullDisplay();
}
ConstantMapVector.removeAllElements();
}
DisplayImpl local_d = (DisplayImpl) getLocalAction();
Display d = (Display) getAction();
if (constant_maps != null) {
for (int i=0; i= 0) defaultValues[index] = (float) map.getConstant();
// defaultValues[map.getDisplayScalarIndex()] = (float) map.getConstant();
}
try {
renderer.clearExceptions();
DisplayImpl local_dpy = (DisplayImpl )local_action;
shadow = type.buildShadowType(this, null);
ShadowType adaptedShadow = shadow.getAdaptedShadowType();
indices = ShadowType.zeroIndices(local_dpy.getScalarCount());
display_indices = ShadowType.zeroIndices(
local_dpy.getDisplayScalarCount());
value_indices = ShadowType.zeroIndices(local_dpy.getValueArrayLength());
final int numControls = local_dpy.getNumberOfControls();
isTransform = new boolean[numControls];
for (int i=0; itrue
if and only if this instance equals o.
*/
public boolean equals(Object o)
{
if (!(o instanceof DataDisplayLink)) {
return false;
}
DataDisplayLink ddl = (DataDisplayLink )o;
if (!getDataReference().equals(ddl.getDataReference())) {
return false;
}
if (!getDisplay().equals(ddl.getDisplay())) {
return false;
}
return true;
}
}
Ads help maintain this website.