Search in sources :

Example 6 with Range

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

the class Plot2DPanel method setXAutoRange.

/**
 * Sets the xAutoRange property (cbit.image.Range) value.
 * @param xAutoRange The new value for the property.
 * @see #getXAutoRange
 */
public void setXAutoRange(Range xAutoRange) {
    Range oldValue = fieldXAutoRange;
    fieldXAutoRange = xAutoRange;
    firePropertyChange("xAutoRange", oldValue, xAutoRange);
}
Also used : Range(org.vcell.util.Range)

Example 7 with Range

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

the class Plot2DPanel method updateAutoRanges.

protected void updateAutoRanges() {
    if (getPlot2D() == null)
        return;
    if (getPlot2D().visiblePlotsInvalid()) {
        setXAutoRange(null);
        setYAutoRange(null);
        return;
    }
    if (getXStretch()) {
        setXAutoRange(getPlot2D().getXDataRange());
    } else {
        setXAutoRange(NumberUtils.getDecimalRange(getPlot2D().getXDataRange(), false, false));
    }
    if (getYStretch()) {
        if (getIsHistogram()) {
            Range temp = getPlot2D().getYDataRange();
            Range yRange = new Range(temp.getMin() * 2, temp.getMax() * 2);
            setYAutoRange(yRange);
        } else
            setYAutoRange(getPlot2D().getYDataRange());
    } else {
        if (getIsHistogram()) {
            Range temp = getPlot2D().getYDataRange();
            Range yRange = new Range(temp.getMin() * 2, temp.getMax() * 2);
            setYAutoRange(NumberUtils.getDecimalRange(yRange, false, false));
        } else
            setYAutoRange(NumberUtils.getDecimalRange(getPlot2D().getYDataRange(), false, false));
    }
}
Also used : Range(org.vcell.util.Range)

Example 8 with Range

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

the class Plot2DPanel method setXManualRange.

/**
 * Sets the xManualRange property (cbit.image.Range) value.
 * @param xManualRange The new value for the property.
 * @see #getXManualRange
 */
public void setXManualRange(Range xManualRange) {
    if (xManualRange != null) {
        if (xManualRange.getMin() == xManualRange.getMax()) {
            xManualRange = new Range(xManualRange.getMin() - 1, xManualRange.getMin() + 1);
        }
    }
    if (getBCompact()) {
        if (xManualRange != null) {
            final int COMP_XVAL_MAX_LEN = 9;
            xCompactMinS = xManualRange.getMin() + "";
            if (xCompactMinS.length() > COMP_XVAL_MAX_LEN) {
                DecimalFormat df = new DecimalFormat();
                df.applyPattern("#.###E0");
                xCompactMinS = df.format(xManualRange.getMin());
            }
            xCompactMaxS = xManualRange.getMax() + "";
            if (xCompactMaxS.length() > COMP_XVAL_MAX_LEN) {
                DecimalFormat df = new DecimalFormat();
                df.applyPattern("#.###E0");
                xCompactMaxS = df.format(xManualRange.getMax());
            }
        } else {
            xCompactMaxS = "?";
            xCompactMinS = "?";
        }
    }
    Range oldValue = fieldXManualRange;
    fieldXManualRange = xManualRange;
    firePropertyChange("xManualRange", oldValue, xManualRange);
}
Also used : DecimalFormat(java.text.DecimalFormat) Range(org.vcell.util.Range) Point(java.awt.Point) Paint(java.awt.Paint)

Example 9 with Range

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

the class Plot2DPanel method updateAxes.

/**
 * Comment
 */
private void updateAxes() {
    Range xR = getXAuto() ? getXAutoRange() : getXManualRange();
    Range yR = getYAuto() ? getYAutoRange() : getYManualRange();
    bPlot2DHasInvalidRange = false;
    if (xR != null) {
        bPlot2DHasInvalidRange = bPlot2DHasInvalidRange || !xR.isValid();
    }
    if (yR != null) {
        bPlot2DHasInvalidRange = bPlot2DHasInvalidRange || !yR.isValid();
    }
    if (getPlot2D() == null || getPlot2D().visiblePlotsInvalid() || bPlot2DHasInvalidRange) {
        setXMajorTicks(null);
        setYMajorTicks(null);
        setXMinorTicks(null);
        setYMinorTicks(null);
        repaint();
        return;
    }
    xR = xR == null ? new Range(-1, 1) : xR;
    yR = yR == null ? new Range(-1, 1) : yR;
    double[] xM = NumberUtils.getMajorDecimalTicks(xR);
    double[] yM = NumberUtils.getMajorDecimalTicks(yR);
    int xl = xM.length;
    int xs = 0;
    if (xM[0] < xR.getMin()) {
        xl--;
        xs++;
    }
    if (xM[xM.length - 1] > xR.getMax()) {
        xl--;
    }
    double[] xMajorTicks = new double[xl];
    System.arraycopy(xM, xs, xMajorTicks, 0, xl);
    int yl = yM.length;
    int ys = 0;
    if (yM[0] < yR.getMin()) {
        yl--;
        ys++;
    }
    if (yM[yM.length - 1] > yR.getMax()) {
        yl--;
    }
    double[] yMajorTicks = new double[yl];
    System.arraycopy(yM, ys, yMajorTicks, 0, yl);
    setXMajorTicks(xMajorTicks);
    setYMajorTicks(yMajorTicks);
    setXMinorTicks(NumberUtils.getMinorDecimalTicks(xR));
    setYMinorTicks(NumberUtils.getMinorDecimalTicks(yR));
    repaint();
}
Also used : Range(org.vcell.util.Range) Point(java.awt.Point) Paint(java.awt.Paint)

Example 10 with Range

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

the class PDEDataContextPanel method recodeDataForDomain0.

private void recodeDataForDomain0() {
    Domain varDomain = getPdeDataContext().getDataIdentifier().getDomain();
    double[] tempRecodedData = null;
    Range dataRange = null;
    VariableType vt = getPdeDataContext().getDataIdentifier().getVariableType();
    boolean bRecoding = getDataInfoProvider() != null && varDomain != null;
    Double notInDomainValue = null;
    if (getPdeDataContext().getDataValues() != originalData || recodeDataForDomainInfo == null || ((getDataInfoProvider() == null) != bDataInfoProviderNull) || !Compare.isEqualOrNull(functionStatisticsRange, lastFunctionStatisticsRange)) {
        lastFunctionStatisticsRange = functionStatisticsRange;
        bDataInfoProviderNull = (getDataInfoProvider() == null);
        originalData = getPdeDataContext().getDataValues();
        tempRecodedData = originalData;
        double illegalNumber = Double.POSITIVE_INFINITY;
        if (bRecoding) {
            tempRecodedData = new double[originalData.length];
            System.arraycopy(originalData, 0, tempRecodedData, 0, tempRecodedData.length);
            for (int i = 0; i < originalData.length; i++) {
                if (!Double.isNaN(originalData[i])) {
                    illegalNumber = Math.min(illegalNumber, originalData[i]);
                }
            }
        }
        // 
        illegalNumber -= 1;
        notInDomainValue = new Double(illegalNumber);
        final CartesianMesh cartesianMesh = getPdeDataContext().getCartesianMesh();
        double minCurrTime = Double.POSITIVE_INFINITY;
        double maxCurrTime = Double.NEGATIVE_INFINITY;
        for (int i = 0; i < tempRecodedData.length; i++) {
            if (bRecoding) {
                if (!isInDomain(cartesianMesh, varDomain, dataInfoProvider, i, vt)) {
                    tempRecodedData[i] = illegalNumber;
                }
            }
            if (!Double.isNaN(tempRecodedData[i]) && tempRecodedData[i] != illegalNumber) {
                minCurrTime = Math.min(minCurrTime, tempRecodedData[i]);
                maxCurrTime = Math.max(maxCurrTime, tempRecodedData[i]);
            }
        }
        if (!getdisplayAdapterService1().getAllTimes() || functionStatisticsRange == null) {
            dataRange = new Range(minCurrTime, maxCurrTime);
        } else if (functionStatisticsRange != null) {
            dataRange = functionStatisticsRange;
        } else {
            throw new RuntimeException("Unexpected state for range calculation");
        }
    } else {
        dataRange = recodeDataForDomainInfo.getRecodedDataRange();
        tempRecodedData = recodeDataForDomainInfo.getRecodedDataForDomain();
    }
    if (bRecoding) {
        recodeDataForDomainInfo = new RecodeDataForDomainInfo(true, tempRecodedData, dataRange, notInDomainValue);
    } else {
        recodeDataForDomainInfo = new RecodeDataForDomainInfo(false, tempRecodedData, dataRange, notInDomainValue);
    }
}
Also used : CartesianMesh(cbit.vcell.solvers.CartesianMesh) VariableType(cbit.vcell.math.VariableType) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) Domain(cbit.vcell.math.Variable.Domain) Range(org.vcell.util.Range) SinglePoint(cbit.vcell.geometry.SinglePoint)

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