Permalink
Browse files

User Interface extended with factor entry fields.

  • Loading branch information...
1 parent 15bc9d1 commit 410ee19d58dc988333e1dafa9238609fd8a6ff7f @mnemonia committed Mar 12, 2012
@@ -6,6 +6,8 @@
public void setImportFile(File file);
public void setExportFile(File file);
public void go();
- public void setFValue(int value);
- public void setSValue(int value);
+ public void setFFactor(int value);
+ public void setFScaling(int value);
+ public void setSFactor(int value);
+ public void setSScaling(int value);
}
@@ -9,7 +9,9 @@
public final class GCodeTransformerImpl implements GCodeTransformer {
private File in,out;
private int fScaling = 1;
+ private int fFactor = 60;
private int sScaling = 1;
+ private int sFactor = 1;
public GCodeTransformerImpl(){
in = new File("C:/in.gcode");
@@ -18,10 +20,9 @@ public GCodeTransformerImpl(){
@Override
public void go() {
- System.out.println("GCodeTransformerImpl.go(fScaling:"+fScaling+", sScaling:"+sScaling+")");
new TransformerImpl(
- new ScaleValuesTransformation("F",60,fScaling),
- new ScaleValuesTransformation("S",1,sScaling)
+ new ScaleValuesTransformation("F",fFactor,fScaling),
+ new ScaleValuesTransformation("S",sFactor,sScaling)
).transform(in, out);
}
@@ -31,7 +32,7 @@ public void setExportFile(File out) {
}
@Override
- public void setFValue(int value) {
+ public void setFScaling(int value) {
fScaling = value;
}
@@ -41,8 +42,18 @@ public void setImportFile(File file) {
}
@Override
- public void setSValue(int value) {
+ public void setSScaling(int value) {
sScaling = value;
}
+ @Override
+ public void setFFactor(int value) {
+ fFactor = value;
+ }
+
+ @Override
+ public void setSFactor(int value) {
+ sFactor = value;
+ }
+
}
@@ -2,20 +2,21 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
+import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Hashtable;
import javax.swing.JButton;
-import javax.swing.JColorChooser;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
+import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -25,6 +26,8 @@
/**
*
*/
+ JTextField fFactorField;
+ JTextField sFactorField;
private static final long serialVersionUID = 1L;
private final GCodeTransformer gCodeTransformer;
@@ -50,13 +53,32 @@ private void addStatusBar() {
}
private void addParametrisation() {
- JPanel parametrisation = new JPanel(new GridLayout(1,2));
+ JPanel parametrisation = new JPanel(new GridLayout(1,3));
add(parametrisation,BorderLayout.CENTER);
- JPanel param = new JPanel(new BorderLayout());
+ JPanel param = new JPanel(new FlowLayout());
parametrisation.add(param);
- JLabel fLabel = new JLabel("Adjust F Value", JLabel.CENTER);
+ JPanel p = new JPanel(new BorderLayout());
+ param.add(p);
+
+ JLabel fLabel = new JLabel("F Factor");
+ p.add(fLabel, BorderLayout.WEST);
+ fFactorField = new JTextField("60", JLabel.SOUTH);
+ p.add(fFactorField, BorderLayout.CENTER);
+
+ p = new JPanel(new BorderLayout());
+ param.add(p);
+
+ JLabel sLabel = new JLabel("S Factor");
+ p.add(sLabel, BorderLayout.WEST);
+ sFactorField = new JTextField("1", JLabel.SOUTH);
+ p.add(sFactorField, BorderLayout.CENTER);
+
+ param = new JPanel(new BorderLayout());
+ parametrisation.add(param);
+
+ fLabel = new JLabel("Adjust F Value", JLabel.CENTER);
fLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
param.add(fLabel, BorderLayout.NORTH);
final JSlider f = new JSlider(JSlider.VERTICAL,1,200,100);
@@ -65,22 +87,26 @@ private void addParametrisation() {
@Override
public void stateChanged(ChangeEvent e) {
- gCodeTransformer.setFValue((int)f.getValue());
+ gCodeTransformer.setFScaling(f.getValue());
}
});
f.setMajorTickSpacing(10);
f.setPaintTicks(true);
- Hashtable labelTable = new Hashtable();
+ Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
labelTable.put( new Integer( 1 ), new JLabel("1%") );
labelTable.put( new Integer( 100 ), new JLabel("100%") );
labelTable.put( new Integer( 200 ), new JLabel("200%") );
f.setLabelTable( labelTable );
f.setPaintLabels(true);
+ fLabel = new JLabel("0", JLabel.CENTER);
+ fLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
+ param.add(fLabel, BorderLayout.SOUTH);
+
param = new JPanel(new BorderLayout());
parametrisation.add(param);
- JLabel sLabel = new JLabel("Adjust S Value", JLabel.CENTER);
+ sLabel = new JLabel("Adjust S Value", JLabel.CENTER);
fLabel.setAlignmentX(JComponent.CENTER_ALIGNMENT);
param.add(sLabel, BorderLayout.NORTH);
final JSlider s = new JSlider(JSlider.VERTICAL,1,200,100);
@@ -90,7 +116,7 @@ public void stateChanged(ChangeEvent e) {
@Override
public void stateChanged(ChangeEvent e) {
- gCodeTransformer.setSValue((int)s.getValue());
+ gCodeTransformer.setSScaling(s.getValue());
}
});
s.setMajorTickSpacing(10);
@@ -146,6 +172,8 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {
+ gCodeTransformer.setFFactor(Integer.parseInt(fFactorField.getText()));
+ gCodeTransformer.setSFactor(Integer.parseInt(sFactorField.getText()));
gCodeTransformer.go();
}
});

0 comments on commit 410ee19

Please sign in to comment.