Search in sources :

Example 36 with Range

use of org.vcell.util.Range in project vcell by virtualcell.

the class PDEOffscreenRenderer method getScaledRGBVolume.

private BufferedImage getScaledRGBVolume(CartesianMesh mesh, int meshMode, int imageScale, boolean bBackground) {
    Dimension dim = FormatSpecificSpecs.getMeshDimensionUnscaled(getNormalAxis(), getServerPDEDataContext().getCartesianMesh());
    int width = (int) dim.getWidth();
    int height = (int) dim.getHeight();
    double[] volumeData = new double[width * height];
    if (!bBackground) {
        // if(bNeedsDefaultScaling){setDefaultScaling();}
        double notInDomainValue = getDisplayAdapterService().getValueDomain().getMin() - 1.0;
        double[] values = getServerPDEDataContext().getDataValues();
        int[] dataIndices = getServerPDEDataContext().getCartesianMesh().getVolumeSliceIndices(getNormalAxis(), getSlice());
        for (int i = 0; i < dataIndices.length; i++) {
            double value = values[dataIndices[i]];
            if (domainValid != null) {
                if (domainValid.get(dataIndices[i]) || domainValid.isEmpty()) {
                    volumeData[i] = value;
                } else {
                    volumeData[i] = notInDomainValue;
                }
            } else {
                volumeData[i] = value;
            }
        }
    }
    SourceDataInfo sourceDataInfo = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, volumeData, mesh.getExtent(), mesh.getOrigin(), new Range(0, 1), 0, width, 1, height, width, 1, 0);
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setSourceData(sourceDataInfo);
    imagePaneModel.setBackgroundColor(Color.black);
    imagePaneModel.setDisplayAdapterService(getDisplayAdapterService());
    // getDisplayAdapterService().setActiveScaleRange(new Range(0,1));
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    imagePaneModel.setViewport(new Rectangle(imagePaneModel.getScaledLength(width), imagePaneModel.getScaledLength(height)));
    imagePaneModel.updateViewPortImage();
    if (bBackground) {
        int[] internalBuffer = ((DataBufferInt) (imagePaneModel.getViewPortImage().getRaster().getDataBuffer())).getData();
        Arrays.fill(internalBuffer, getDisplayAdapterService().getSpecialColors()[DisplayAdapterService.NULL_COLOR_OFFSET]);
    }
    BufferedImage bufferedImage = imagePaneModel.getViewPortImage();
    imagePaneModel.setDisplayAdapterService(null);
    return bufferedImage;
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) DataBufferInt(java.awt.image.DataBufferInt) SourceDataInfo(cbit.image.SourceDataInfo) Range(org.vcell.util.Range) BufferedImage(java.awt.image.BufferedImage)

Example 37 with Range

use of org.vcell.util.Range in project vcell by virtualcell.

the class KymographPanel method configurePlotData.

/**
 * Insert the method's description here.
 * Creation date: (12/16/2004 10:46:05 AM)
 * @param imgX int
 * @param imgY int
 */
private void configurePlotData(int imgX, int imgY) {
    // 
    // TimeScan Data
    // 
    double[][] timeData = new double[2][currentTimes.length];
    timeData[0] = currentTimes;
    timeData[1] = new double[currentTimes.length];
    for (int i = 0; i < currentTimes.length; i += 1) {
        // timeData[1][i] = timeSeriesDataOrig[1+imgX][i];
        timeData[1][i] = rawValues[imgX + (i * RESAMP_SIZE)];
    }
    ;
    localTimeDataMMMH = calcMMM(timeData[1]);
    final int MAX_TITLE_VAL_LENGTH = 9;
    DecimalFormat nf = new DecimalFormat();
    String valS = null;
    valS = currentDistances[imgX] + "";
    if (valS.length() > MAX_TITLE_VAL_LENGTH) {
        nf.applyPattern("#.###E0");
        valS = nf.format(currentDistances[imgX]);
    }
    currentTimeSeriesPlot2D = new SingleXPlot2D(new SymbolTableEntry[] { currentSymbolTablEntry }, multiTimePlotHelper.getDataSymbolMetadataResolver(), "Time", new String[] { currentDataIdentifier.getName() }, timeData, new String[] { "Time Series (d=" + valS + ") Vert", "Time", /*"Time (s)"*/
    "Value" });
    getPlotPaneTimeSeries().setPlot2D(currentTimeSeriesPlot2D);
    // 
    // LineScan Data
    // 
    double[] lineData = new double[timeSeriesDataOrig.length - 1];
    for (int i = 1; i < timeSeriesDataOrig.length; i += 1) {
        lineData[i - 1] = timeSeriesDataOrig[i][imgY];
    }
    double[] lineScanDistances = accumDistancesDataOrig;
    localDistDataMMMH = calcMMM(lineData);
    PlotData plotData = new PlotData(lineScanDistances, lineData);
    valS = currentTimes[imgY] + "";
    if (valS.length() > MAX_TITLE_VAL_LENGTH) {
        valS = nf.format(currentTimes[imgY]);
    }
    currentLineScanPlot2D = new Plot2D(new SymbolTableEntry[] { currentSymbolTablEntry }, multiTimePlotHelper.getDataSymbolMetadataResolver(), new String[] { currentDataIdentifier.getName() }, new PlotData[] { plotData }, new String[] { "Line Scan (t=" + valS + ") Horz", "Distance", /*"Distance (\u00b5m)"*/
    "Value" });
    getPlotPaneLineScan().setPlot2D(currentLineScanPlot2D);
    Range xRangeTime = new Range(currentTimes[0], currentTimes[currentTimes.length - 1]);
    Range xRangeDist = new Range(lineScanDistances[0], lineScanDistances[lineScanDistances.length - 1]);
    Range yRangeTime = (allDataMMMH != null ? allDataMMMH.getRange() : null);
    Range yRangeDist = yRangeTime;
    if (bLocalScaling) {
        yRangeTime = (localTimeDataMMMH != null ? localTimeDataMMMH.getRange() : null);
        yRangeDist = (localDistDataMMMH != null ? localDistDataMMMH.getRange() : null);
    }
    getPlotPaneTimeSeries().forceXYRange(xRangeTime, yRangeTime);
    getPlotPaneLineScan().forceXYRange(xRangeDist, yRangeDist);
    configureMinMax();
    getimagePaneView1().repaint();
}
Also used : PlotData(cbit.plot.PlotData) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) DecimalFormat(java.text.DecimalFormat) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) Range(org.vcell.util.Range) Point(java.awt.Point) SingleXPlot2D(cbit.plot.SingleXPlot2D)

Example 38 with Range

use of org.vcell.util.Range in project vcell by virtualcell.

the class PDEDataViewer method calcAutoAllTimes.

private void calcAutoAllTimes() throws Exception {
    HashSet<String> stateVarNames = null;
    Variable theVariable = null;
    boolean bStateVar = true;
    boolean isFieldData = getPdeDataContext().getVCDataIdentifier() instanceof ExternalDataIdentifier || getPdeDataContext().getVCDataIdentifier() instanceof MergedDataInfo;
    if (isFieldData) {
        // fielddata
        DataIdentifier[] dataids = getPdeDataContext().getDataIdentifiers();
        stateVarNames = new HashSet<>();
        for (int i = 0; i < dataids.length; i++) {
            if (!dataids[i].isFunction()) {
                stateVarNames.add(dataids[i].getName());
            }
        // System.out.println("name:'"+dataids[i].getName()+"' type:"+dataids[i].getVariableType()+" func:"+dataids[i].isFunction());
        }
        bStateVar = !getPdeDataContext().getDataIdentifier().isFunction();
        if (bStateVar) {
            theVariable = new VolVariable(getPdeDataContext().getDataIdentifier().getName(), getPdeDataContext().getDataIdentifier().getDomain());
        } else {
            AnnotatedFunction[] funcs = getPdeDataContext().getFunctions();
            for (int i = 0; i < funcs.length; i++) {
                if (funcs[i].getName().equals(getPdeDataContext().getDataIdentifier().getName())) {
                    theVariable = funcs[i];
                    break;
                }
            }
        }
    } else {
        stateVarNames = getSimulation().getMathDescription().getStateVariableNames();
        theVariable = getSimulation().getMathDescription().getVariable(getPdeDataContext().getVariableName());
        if (theVariable == null) {
            theVariable = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext().getOutputFunction(getPdeDataContext().getVariableName());
        }
        if (theVariable == null) {
            DataProcessingOutputInfo dataProcessingOutputInfo = DataProcessingResultsPanel.getDataProcessingOutputInfo(getPdeDataContext());
            if (dataProcessingOutputInfo != null && Arrays.asList(dataProcessingOutputInfo.getVariableNames()).contains(getPdeDataContext().getVariableName())) {
                // PostProcess Variable
                return;
            }
        }
        bStateVar = stateVarNames.contains(getPdeDataContext().getVariableName());
    }
    if (theVariable == null) {
        throw new Exception("Unexpected Alltimes... selected variable '" + getPdeDataContext().getVariableName() + "' is not stateVariable or OutputFunction");
    }
    if (getPDEDataContextPanel1().getdisplayAdapterService1().getAllTimes()) {
        // min-max over all timepoints (allTimes)
        if (theVariable.isConstant()) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
            double constVal = theVariable.getExpression().evaluateConstant();
            getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(constVal, constVal));
        } else if (bStateVar) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
            ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), new String[] { theVariable.getName() });
            if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
                // no postprocessinfo
                return;
            }
            FunctionStatistics functionStatistics = new FunctionStatistics(varStatsArr.get(0).minValuesOverTime, varStatsArr.get(0).maxValuesOverTime);
            getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
        } else if (theVariable instanceof Function) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
            Function flattened = MathDescription.getFlattenedFunctions(SimulationSymbolTable.createMathSymbolTableFactory(), getSimulation().getMathDescription(), new String[] { theVariable.getName() })[0];
            if (flattened == null) {
                flattened = (Function) theVariable;
            }
            ArrayList<VarStatistics> varStatsArr = calcVarStat(getPdeDataContext(), stateVarNames.toArray(new String[0]));
            if (errorAutoAllTimes(varStatsArr != null, (varStatsArr == null ? null : varStatsArr.size() > 0), isFieldData)) {
                // check for no postprocessinfo
                return;
            }
            if (varStatsArr.size() == stateVarNames.size()) {
                if (getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().getRegionImage() == null) {
                    getSimulation().getMeshSpecification().getGeometry().getGeometrySurfaceDescription().updateAll();
                }
                FunctionStatistics functionStatistics = FunctionRangeGenerator.getFunctionStatistics(flattened.getExpression(), varStatsArr.toArray(new VarStatistics[0]), getPdeDataContext().getTimePoints(), getPdeDataContext().getCartesianMesh(), calcInDomainBitSet(), getPdeDataContext().getDataIdentifier().getVariableType());
                getPDEDataContextPanel1().setFunctionStatisticsRange(new Range(functionStatistics.getMinOverTime(), functionStatistics.getMaxOverTime()));
            } else {
                throw new Exception("Unexpectede AllTimes... calculated state var stats size != mathdescr state var size");
            }
        } else {
            throw new Exception("Unexpected AllTimes... not constant, stateVar or function");
        }
    } else {
        // min-max at each timepoint (currTime)
        if (!(theVariable instanceof Function)) {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__STATE_TEXT);
        } else {
            getPDEDataContextPanel1().getdisplayAdapterServicePanel1().changeAllTimesButtonText(DisplayAdapterServicePanel.ALL_TIMES__APPROX_TEXT);
        }
        getPDEDataContextPanel1().setFunctionStatisticsRange(null);
    }
}
Also used : VolVariable(cbit.vcell.math.VolVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) Variable(cbit.vcell.math.Variable) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) VolVariable(cbit.vcell.math.VolVariable) ArrayList(java.util.ArrayList) Range(org.vcell.util.Range) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UserCancelException(org.vcell.util.UserCancelException) MergedDataInfo(cbit.vcell.simdata.MergedDataInfo) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) VarStatistics(cbit.vcell.util.FunctionRangeGenerator.VarStatistics) DataProcessingOutputInfo(cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) FunctionStatistics(cbit.vcell.util.FunctionRangeGenerator.FunctionStatistics)

Example 39 with Range

use of org.vcell.util.Range in project vcell by virtualcell.

the class KymographPanel method initStandAloneTimeSeries_private.

/**
 * Insert the method's description here.
 * Creation date: (12/14/2004 9:47:38 AM)
 * @param timeSeries double[][]
 * @param distances double[]
 */
private void initStandAloneTimeSeries_private(double[][] timeSeriesOrig, double[] accumDistancesOrig) throws DataAccessException {
    if (accumDistancesOrig.length != (timeSeriesOrig.length - 1)) {
        throw new IllegalArgumentException(this.getClass().getName() + " accumDistances.length != numSamplePoints");
    }
    timeSeriesDataOrig = timeSeriesOrig;
    accumDistancesDataOrig = accumDistancesOrig;
    currentTimes = timeSeriesDataOrig[0];
    // Resample for even distances
    RESAMP_SIZE = timeSeriesDataOrig.length - 1;
    int rvSize = (currentTimes.length) * RESAMP_SIZE;
    rawValues = new double[rvSize];
    double incr = accumDistancesDataOrig[accumDistancesDataOrig.length - 1] / (double) (RESAMP_SIZE - 1);
    currentDistances = new double[RESAMP_SIZE];
    for (int j = 0; j < currentTimes.length; j += 1) {
        int sourceIndex = 0;
        double currentDistance = 0;
        for (int k = 0; k < RESAMP_SIZE; k += 1) {
            while (currentDistance > accumDistancesDataOrig[sourceIndex + 1]) {
                sourceIndex += 1;
            }
            double subShort = currentDistance - accumDistancesDataOrig[sourceIndex];
            double subLong = accumDistancesDataOrig[sourceIndex + 1] - accumDistancesDataOrig[sourceIndex];
            double proportion = subShort / subLong;
            // System.out.println("prop="+proportion+" j="+j+" k="+k+" sourceIndex="+sourceIndex+"sourcedist="+accumDistancesDataOrig[sourceIndex]+" currentDistance="+currentDistance);
            double value = timeSeriesDataOrig[1 + sourceIndex + (proportion > .5 ? 1 : 0)][j];
            // double value = timeSeriesDataOrig[1+sourceIndex][j] + ((timeSeriesDataOrig[1+sourceIndex+1][j]-timeSeriesDataOrig[1+sourceIndex][j])*proportion);
            // if(k == (RESAMP_SIZE-1)){
            // value = timeSeriesDataOrig[timeSeriesDataOrig.length-1][j];
            // }
            rawValues[(j * RESAMP_SIZE) + (k)] = value;
            currentDistances[k] = currentDistance;
            currentDistance += incr;
            if (currentDistance > accumDistancesDataOrig[accumDistancesDataOrig.length - 1]) {
                currentDistance = accumDistancesDataOrig[accumDistancesDataOrig.length - 1];
            }
        }
    }
    Range minmaxRange = null;
    allDataMMMH = calcMMM(rawValues);
    if (allDataMMMH != null) {
        minmaxRange = allDataMMMH.getRange();
    }
    SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, rawValues, minmaxRange, 0, RESAMP_SIZE, 1, 0, accumDistancesDataOrig[accumDistancesDataOrig.length - 1], currentTimes.length, RESAMP_SIZE, currentTimes[0], currentTimes[currentTimes.length - 1] - currentTimes[0]);
    getImagePaneScroller1().getImagePaneModel().setSourceData(sdi);
    getImagePlaneManager1().setSourceDataInfo(sdi);
    if (isInit) {
        zoomUpJButton_ActionPerformed(null);
        zoomDownJButton_ActionPerformed(null);
    // getImagePaneScroller1().getImagePaneModel().changeZoomToFillViewport();
    }
    getDisplayJLabel().setText(NONE_MESSAGE);
    configurePlotData(currentSelectionImg.x, currentSelectionImg.y);
}
Also used : Range(org.vcell.util.Range) SourceDataInfo(cbit.image.SourceDataInfo) Point(java.awt.Point)

Example 40 with Range

use of org.vcell.util.Range in project vcell by virtualcell.

the class HistogramPanel method getDragRange.

private Range getDragRange(Point dragReleasePoint) {
    SortedMap<Integer, Integer> subsetTreeMap = getTreeMapView();
    Point dragStartPointTemp = mouseStartPoint;
    if (dragStartPointTemp.x > dragReleasePoint.x) {
        Point temp = dragStartPointTemp;
        dragStartPointTemp = dragReleasePoint;
        dragReleasePoint = temp;
    }
    int dragStartIndex = getHorizontalIndex(dragStartPointTemp.x, subsetTreeMap.size());
    int dragReleaseIndex = getHorizontalIndex(dragReleasePoint.x, subsetTreeMap.size());
    int dragReleaseNextIndex = getHorizontalIndex(dragReleasePoint.x + 1, subsetTreeMap.size());
    int startPixelVal = dragStartIndex + subsetTreeMap.firstKey();
    int endPixelVal = (dragReleaseIndex + subsetTreeMap.firstKey());
    if (dragReleaseNextIndex - dragReleaseIndex > 1) {
        endPixelVal = (dragReleaseNextIndex - 1 + subsetTreeMap.firstKey());
    }
    return new Range(startPixelVal, endPixelVal);
}
Also used : Point(java.awt.Point) Range(org.vcell.util.Range) Point(java.awt.Point)

Aggregations

Range (org.vcell.util.Range)54 Point (java.awt.Point)12 SourceDataInfo (cbit.image.SourceDataInfo)5 Paint (java.awt.Paint)4 DecimalFormat (java.text.DecimalFormat)4 DisplayAdapterService (cbit.image.DisplayAdapterService)3 SinglePoint (cbit.vcell.geometry.SinglePoint)3 SpatialAnalysisResults (cbit.vcell.microscopy.SpatialAnalysisResults)3 DisplayPreferences (cbit.image.DisplayPreferences)2 Plot2D (cbit.plot.Plot2D)2 PlotData (cbit.plot.PlotData)2 ExportEvent (cbit.rmi.event.ExportEvent)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 VariableType (cbit.vcell.math.VariableType)2 VolVariable (cbit.vcell.math.VolVariable)2 MergedDataInfo (cbit.vcell.simdata.MergedDataInfo)2 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)2 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)2