use of org.vcell.util.Range in project vcell by virtualcell.
the class Plot2DPanel method getTransform.
/**
* Returns an AffineTrasform that maps a cartesian rectangular area bounded by
* the stored X axis and Y axis values to the current plotting area of this panel.
* Creation date: (2/8/2001 11:02:15 PM)
* @return java.awt.geom.AffineTransform
*/
private AffineTransform getTransform() {
Range xR = getXAuto() ? getXAutoRange() : getXManualRange();
Range yR = getYAuto() ? getYAutoRange() : getYManualRange();
xR = xR == null ? new Range(-1, 1) : xR;
yR = yR == null ? new Range(-1, 1) : yR;
// these go in reverse order !
AffineTransform transform = AffineTransform.getTranslateInstance(getTick() + getLMargin(), getTick() + getTMargin());
transform.concatenate(AffineTransform.getScaleInstance((getWidth() - 2 * getTick() - getLMargin() - getRMargin()) / (xR.getMax() - xR.getMin()), (getHeight() - 2 * getTick() - getTMargin() - getBMargin()) / (yR.getMin() - yR.getMax())));
transform.concatenate(AffineTransform.getTranslateInstance(-xR.getMin(), -yR.getMax()));
return transform;
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class Plot2DPanel method setYManualRange.
/**
* Sets the yManualRange property (cbit.image.Range) value.
* @param yManualRange The new value for the property.
* @see #getYManualRange
*/
public void setYManualRange(Range yManualRange) {
if (yManualRange != null && (yManualRange.getMin() == yManualRange.getMax())) {
yManualRange = new Range(yManualRange.getMin() - 1, yManualRange.getMin() + 1);
}
if (getBCompact()) {
setLMargin(20);
if (yManualRange != null) {
final int COMP_YVAL_MAX_LEN = 5;
yCompactMinS = yManualRange.getMin() + "";
if (yCompactMinS.length() > COMP_YVAL_MAX_LEN) {
DecimalFormat df = new DecimalFormat();
df.applyPattern("#.##E0");
yCompactMinS = df.format(yManualRange.getMin());
}
yCompactMaxS = yManualRange.getMax() + "";
if (yCompactMaxS.length() > COMP_YVAL_MAX_LEN) {
DecimalFormat df = new DecimalFormat();
df.applyPattern("#.##E0");
yCompactMaxS = df.format(yManualRange.getMax());
}
} else {
yCompactMaxS = "?";
yCompactMinS = "?";
}
}
Range oldValue = fieldYManualRange;
fieldYManualRange = yManualRange;
firePropertyChange("yManualRange", oldValue, yManualRange);
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class Plot2DPanel method setYAutoRange.
/**
* Sets the yAutoRange property (cbit.image.Range) value.
* @param yAutoRange The new value for the property.
* @see #getYAutoRange
*/
public void setYAutoRange(Range yAutoRange) {
Range oldValue = fieldYAutoRange;
fieldYAutoRange = yAutoRange;
firePropertyChange("yAutoRange", oldValue, yAutoRange);
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class Plot2DSettingsPanel method newRangeFromInput.
/**
* Comment
*/
private Range newRangeFromInput(Range currentRange, String typedValue, boolean isMin) {
double newValue = 0;
Range newRange = null;
try {
newValue = Double.parseDouble(typedValue);
} catch (NumberFormatException exc) {
// user typed crap, put back old values
return (Range) currentRange.clone();
}
if (isMin) {
newRange = new Range(newValue, currentRange.getMax());
} else {
newRange = new Range(currentRange.getMin(), newValue);
}
if (newRange.getMin() != newRange.getMax()) {
return newRange;
} else {
// can't scale properly on a zero-length interval...
return (Range) currentRange.clone();
}
}
Aggregations