Skip to content
Snippets Groups Projects
Commit 1627a640 authored by Michael Heyde's avatar Michael Heyde
Browse files

fixed advanced panel bug. Shows now the correct data value

parent 7dbacd9f
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,8 @@ public class TransferFunction1D {
private final TreeMap<Point2D.Float,Color> colors = new TreeMap<Point2D.Float, Color>(pointOrderXOperator);
private float maxVolumeValue;
private boolean isPointValid(Point2D.Float point){
//min
if(point.x < minOrdinates.x || point.y < minOrdinates.y ){
......@@ -173,7 +175,9 @@ public class TransferFunction1D {
* @param maxOrdinates the maxOrdinates to set
*/
public void setMaxOrdinates(Point2D.Float maxOrdinates) {
maxVolumeValue = maxOrdinates.x;
maxOrdinates.x = (maxOrdinates.x > 1000)?1000:maxOrdinates.x;
Point2D.Float oldMax = new Point2D.Float(this.maxOrdinates.x,this.maxOrdinates.y);
this.maxOrdinates = maxOrdinates;
......@@ -435,4 +439,12 @@ public class TransferFunction1D {
return query;
}
public float getDataVolumeValue(float tfVolumeValue){
return (maxVolumeValue/maxOrdinates.x)*tfVolumeValue;
}
public float getTransferFunctionVolumeValue(float dataVolumeValue){
return (maxOrdinates.x/maxVolumeValue)*dataVolumeValue;
}
}
......@@ -389,7 +389,7 @@ public class SceneControlsWindow extends JFrame {
public void dataUpdated(Integer i) {
float maxVolume=Math.min(dataManager.getGlobalMaxVolumeValue(),1000);
transferFunction.setMaxOrdinates(new Point2D.Float(maxVolume, 1.0f));
transferFunction.setMaxOrdinates(new Point2D.Float(dataManager.getGlobalMaxVolumeValue(), 1.0f));
float lowestDataPoint = dataManager.getGlobalLowestVolumeValue();
transferFunction.resetColors();
transferFunction.setColor(new Point2D.Float((maxVolume/dataManager.getGlobalMaxVolumeValue())*lowestDataPoint, 0.001f),
......
......@@ -16,6 +16,8 @@ import javax.swing.event.ChangeListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import bdv.jogl.VolumeRenderer.TransferFunctions.TransferFunction1D;
public class PointCellEditor extends AbstractCellEditor implements TableCellEditor, TableCellRenderer{
......@@ -24,12 +26,14 @@ public class PointCellEditor extends AbstractCellEditor implements TableCellEdit
* default version
*/
private static final long serialVersionUID = 1L;
private Point2D.Float currentPoint;
private final JSpinner xSpinner = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 1000.0, 0.01));
private final TransferFunctionDataPanel parent;
private final JSpinner xSpinner = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 100000.0, 1));
private final JSpinner ySpinner = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 1000.0, 0.01));
private final JSpinner ySpinner = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 100000.0, 1));
private final JPanel editorPanel = new JPanel();
......@@ -43,8 +47,8 @@ public class PointCellEditor extends AbstractCellEditor implements TableCellEdit
editorPanel.add(ySpinner);
};
public PointCellEditor(){
public PointCellEditor(TransferFunctionDataPanel parent){
this .parent = parent;
buildUI();
createControls();
......@@ -58,7 +62,7 @@ public class PointCellEditor extends AbstractCellEditor implements TableCellEdit
if(currentPoint == null){
return;
}
currentPoint.x =((Number)(xSpinner.getValue())).floatValue();
currentPoint.x =parent.getTransferFunction().getTransferFunctionVolumeValue(((Number)(xSpinner.getValue())).floatValue());
fireEditingStopped();
}
});
......@@ -85,7 +89,7 @@ public class PointCellEditor extends AbstractCellEditor implements TableCellEdit
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
currentPoint = (Point2D.Float)value;
xSpinner.setValue(currentPoint.x);
xSpinner.setValue(parent.getTransferFunction().getDataVolumeValue( currentPoint.x));
ySpinner.setValue(currentPoint.y);
return editorPanel;
}
......@@ -94,7 +98,7 @@ public class PointCellEditor extends AbstractCellEditor implements TableCellEdit
public Component getTableCellRendererComponent(JTable arg0, Object value, boolean arg2, boolean arg3, int arg4,
int arg5) {
currentPoint = (Point2D.Float)value;
xSpinner.setValue(currentPoint.x);
xSpinner.setValue(parent.getTransferFunction().getDataVolumeValue(currentPoint.x));
ySpinner.setValue(currentPoint.y);
return editorPanel ;
}
......
......@@ -111,7 +111,7 @@ public class TransferFunctionDataPanel extends JPanel {
});
ColorCellEditor colorEditor = new ColorCellEditor();
PointCellEditor pointEditor = new PointCellEditor();
PointCellEditor pointEditor = new PointCellEditor(this);
colorTable.getColumnModel().getColumn(0).setCellEditor(pointEditor);
colorTable.getColumnModel().getColumn(0).setCellRenderer(pointEditor);
......@@ -138,6 +138,10 @@ public class TransferFunctionDataPanel extends JPanel {
});
}
public TransferFunction1D getTransferFunction(){
return transferFunction;
}
public TransferFunctionDataPanel(final TransferFunction1D tf){
colorTableScroller = new JScrollPane(colorTable);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment