Skip to content
Snippets Groups Projects
Commit a740b89f authored by Junpei Xu's avatar Junpei Xu
Browse files

add comments discribing classes on timestep tab

parent 46f9d2bd
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,13 @@ public class TimelagInputfilter extends DocumentFilter {
public TimelagInputfilter(String pat) {
pattern = Pattern.compile(pat);
}
/**
* @param fb FilterBypass
* @param offset the offset into the document to insert the content >= 0
* @param string the string to insert
* @param attr the attributes to associate with the inserted content
*/
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr)
throws BadLocationException {
if(offset == 0)
......
......@@ -5,11 +5,14 @@ import java.text.ParseException;
import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.text.DocumentFilter;
/**
* this class provide a document filter in which the specify regular expression
* @author Junpei Xu
*
*/
public class TimestepFormatter extends AbstractFormatter{
/**
*
*/
private static final long serialVersionUID = -3758327977666927872L;
public Object stringToValue(String text) throws ParseException {
......@@ -20,6 +23,9 @@ public class TimestepFormatter extends AbstractFormatter{
return (String) value;
}
/**
* regular expression for the filter does not allow negative integer
*/
public DocumentFilter getDocumentFilter(){
return new TimelagInputfilter("[-]+|[-]{1}([0-9]{1}[0-9]*)");
}
......
......@@ -3,6 +3,7 @@ package de.mpg.mpimet.yacgui.ui.dialog.tabpanel;
import java.text.ParseException;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
......@@ -23,6 +24,13 @@ import de.mpg.mpimet.yacgui.xml.CouplingOperation;
import de.mpg.mpimet.yacgui.xml.Timestep;
import de.mpg.mpimet.yacgui.xml.TimestepUnit;
import de.mpg.mpimet.yacgui.xml.TransientCouple;
import de.mpg.mpimet.yacgui.xml.interpolation.NNearestNeighborInterpolation.Weighted;
/**
* Creates components on Timestep tab and provides functions responsible for collecting and loading data
*
* @author Maxim Yastremsky
*/
public class TimestepTab extends AbstractTab {
......@@ -54,7 +62,9 @@ public class TimestepTab extends AbstractTab {
createLayout();
}
/**
* get values from input field to compose timestep
*/
public void collectData() {
Object sourceValue = sourceTimestepInputField.getValue();
Object targetValue = targetTimestepInputField.getValue();
......@@ -74,6 +84,12 @@ public class TimestepTab extends AbstractTab {
}
@Override
/**
* create panel mainly to set format for input fields
* depending on {@link TimestepUnit}, if time step unit was set to be string or ISO format,
* formatter is an instance of {@link TimestepFormatter}, otherwise formatter is an instance
* of {@link NumberFormatter}
*/
protected JPanel createCenterPanel() {
String timestepUnitString = null;
AbstractFormatter formatter = null;
......@@ -141,6 +157,7 @@ public class TimestepTab extends AbstractTab {
sourceTimeLagPanel.add(new JLabel("Source Time Lag: "));
sourceTimeLagInputField = new JFormattedTextField();
timelagFormatter = new TimestepFormatter();
//
// Junpei Xu
sourceTimeLagInputField.setFormatterFactory(new JFormattedTextField.AbstractFormatterFactory() {
@Override
......@@ -192,11 +209,15 @@ public class TimestepTab extends AbstractTab {
sourceTimestepInputField.setValue(timestep.getSource());
targetTimestepInputField.setValue(timestep.getTarget());
couplingPeriodInputField.setValue(timestep.getCouplingPeriod());
//sourceTimeLagInputField.setValue(timestep.getSourceTimeLag());
//targetTimeLagInputField.setValue(timestep.getTargetTimeLag());
break;
default:
sourceTimestepInputField.setValue(new Integer(timestep.getSource()));
targetTimestepInputField.setValue(new Integer(timestep.getTarget()));
couplingPeriodInputField.setValue(new Integer(timestep.getCouplingPeriod()));
//sourceTimeLagInputField.setValue(new Integer(timestep.getSourceTimeLag()));
//targetTimeLagInputField.setValue(new Integer(timestep.getTargetTimeLag()));
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment