use of org.vcell.util.Range in project vcell by virtualcell.
the class HistogramPanel method calcSelectedPixelRanges.
private void calcSelectedPixelRanges(MouseEvent e) {
if (mouseStartPoint != null) {
Range dragRange = getDragRange(e.getPoint());
if (calcRangeBinCount(dragRange) == 0) {
// selected bin range on histogram with no pixels
pixelListSelectionModel.clearSelection();
return;
}
if ((e.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK)) != 0) {
if (!pixelListSelectionModel.isSelectionEmpty() && pixelListSelectionModel.getAnchorSelectionIndex() == pixelListSelectionModel.getLeadSelectionIndex()) {
pixelListSelectionModel.addSelectionInterval(pixelListSelectionModel.getAnchorSelectionIndex(), (int) dragRange.getMin());
}
}
boolean isShiftDown = (e.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK)) != 0;
boolean isCntrlDown = (e.getModifiersEx() & (InputEvent.CTRL_DOWN_MASK)) != 0;
if (isCntrlDown || isShiftDown) {
if (!isShiftDown && dragStartUnselect) {
pixelListSelectionModel.removeSelectionInterval((int) dragRange.getMin(), (int) dragRange.getMax());
} else {
pixelListSelectionModel.addSelectionInterval((int) dragRange.getMin(), (int) dragRange.getMax());
}
} else {
pixelListSelectionModel.setSelectionInterval((int) dragRange.getMin(), (int) dragRange.getMax());
}
}
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class HistogramPanel method getHorzScaleSlider.
private JSlider getHorzScaleSlider() {
if (horzScaleSlider != null) {
return horzScaleSlider;
}
horzScaleSlider = new JSlider();
horzScaleSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (originalTreeMap == null) {
return;
}
int min = getHorzOffsetSlider().getValue();
int interval = originalTreeMap.lastKey() / horzScaleSlider.getValue();
int max = min + interval;
if (max > originalTreeMap.lastKey()) {
min -= (max) - originalTreeMap.lastKey();
}
min = Math.max(originalTreeMap.firstKey(), min);
max = Math.min(max, originalTreeMap.lastKey());
viewPixelRange = new Range(min, max);
horzOffsetSlider.setValue(min);
horzOffsetSlider.setMaximum(originalTreeMap.lastKey() - interval);
updateLowHigh();
getHorzOffsetSlider().setEnabled(getHorzScaleSlider().getValue() > 1);
// moveScrollBar.getModel().setRangeProperties(moveScrollBar.getValue(), interval, min, originalTreeMap.lastKey(),false);
// System.out.println("val="+horzScaleSlider.getValue()+" min="+min+" interv="+interval+" max="+(originalTreeMap.lastKey()-interval));
// System.out.println(" "+moveScrollBar.getModel());
repaint();
}
});
horzScaleSlider.setMinimum(1);
horzScaleSlider.setValue(1);
return horzScaleSlider;
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class DisplayAdapterServicePanel method calculateCustomScaleRange.
/**
* Comment
*/
private void calculateCustomScaleRange() {
try {
double min = Double.parseDouble(getMinTextField().getText());
double max = Double.parseDouble(getMaxTextField().getText());
getDisplayAdapterService().setCustomScaleRange(new Range(min, max));
firePropertyChange(HLE_PROPERTY_ID, true, false);
} catch (NumberFormatException e) {
ensureMinMaxDisplay();
// if(getactiveScaleRange1() != null){
// getMinTextField().setText(getactiveScaleRange1().getMin()+"");
// getMaxTextField().setText(getactiveScaleRange1().getMax()+"");
// }
}
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class DoubleDisplayAdapter method setDataValues.
/**
* Sets the dataValues property (double[]) value.
* @param dataValues The new value for the property.
* @see #getDataValues
*/
public final void setDataValues(double[] dataValues) {
double dataMin = 0;
double dataMax = 0;
if (dataValues != null) {
dataMin = dataValues[0];
dataMax = dataMin;
for (int i = 0; i < dataValues.length; i++) {
dataMin = Math.min(dataMin, dataValues[i]);
dataMax = Math.max(dataMax, dataValues[i]);
}
}
setDataRange(new Range(dataMin, dataMax));
double[] oldValue = fieldDataValues;
fieldDataValues = dataValues;
firePropertyChange("dataValues", oldValue, dataValues);
}
use of org.vcell.util.Range in project vcell by virtualcell.
the class ImageContainerPanel method checkScaleSettingsHistory.
/**
* Comment
*/
public void checkScaleSettingsHistory() throws DataAccessException {
String newDataSet = getImageContainer().getDataID();
if (scaleSettingsHistory.capacity() != 0)
scaleSettingsHistory.setElementAt(getScalePanel1().getScaleRange(), index);
if (dataSetHistory.contains(newDataSet)) {
getScalePanel1().setScaleRange((Range) scaleSettingsHistory.elementAt(dataSetHistory.indexOf(newDataSet)));
} else {
dataSetHistory.addElement(newDataSet);
Range defaultManualRange = new Range(0.0, Math.pow(10, (int) ((Math.log(getScalePanel1().getDataRange().getMax())) / Math.log(10)) + 1));
getScalePanel1().setScaleRange(defaultManualRange);
scaleSettingsHistory.addElement(defaultManualRange);
}
index = dataSetHistory.indexOf(newDataSet);
return;
}
Aggregations