Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added sliders to change F and S values.

  • Loading branch information...
commit e2e126a486d471babf0f9f267db074fe0033d3e9 1 parent 72307b6
@mnemonia authored
View
13 ...andStudioGCodeTransformer/src/com/rocketbrandstudios/gcode/impl/GCodeTransformerImpl.java
@@ -4,9 +4,12 @@
import com.rocketbrandstudios.gcode.GCodeTransformer;
import com.rocketbrandstudios.gcode.service.TransformerImpl;
+import com.rocketbrandstudios.gcode.service.transformer.transformations.ScaleValuesTransformation;
public final class GCodeTransformerImpl implements GCodeTransformer {
private File in,out;
+ private int fScaling;
+ private int sScaling;
public GCodeTransformerImpl(){
in = new File("C:/in.gcode");
@@ -15,7 +18,11 @@ public GCodeTransformerImpl(){
@Override
public void go() {
- new TransformerImpl().transform(in, out);
+
+ new TransformerImpl(
+ new ScaleValuesTransformation("F",60),
+ new ScaleValuesTransformation("S",1)
+ ).transform(in, out);
}
@Override
@@ -25,7 +32,7 @@ public void setExportFile(File out) {
@Override
public void setFValue(int value) {
- System.out.println("setFValue");
+ fScaling = value;
}
@Override
@@ -35,7 +42,7 @@ public void setImportFile(File file) {
@Override
public void setSValue(int value) {
- System.out.println("setSValue");
+ sScaling = value;
}
}
View
8 ...BrandStudioGCodeTransformer/src/com/rocketbrandstudios/gcode/service/TransformerImpl.java
@@ -21,7 +21,7 @@
private final List<Transformation> transformations = new ArrayList<Transformation>();
- public TransformerImpl(){
+ public TransformerImpl(Transformation... t){
add(new AppendM03AfterG90AndG21Transformation());
add(new RemoveLineTransformation("M104"));
add(new RemoveLineTransformation("M105"));
@@ -34,8 +34,10 @@ public TransformerImpl(){
add(new RemoveLineStartTransformation("M108"));
add(new ReplaceLineStartTransformation("M101", "M8"));
add(new ReplaceLineStartTransformation("M103", "M9"));
- add(new ScaleValuesTransformation("F",60));
- add(new ScaleValuesTransformation("S",1));
+
+ for (Transformation transformation : t) {
+ add(transformation);
+ }
}
private void add(Transformation t){
View
58 ...etBrandStudioGCodeTransformer/src/com/rocketbrandstudios/gcode/ui/GCodeTransformerUI.java
@@ -6,12 +6,18 @@
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.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import com.rocketbrandstudios.gcode.GCodeTransformer;
@@ -44,7 +50,57 @@ private void addStatusBar() {
}
private void addParametrisation() {
- // TODO Auto-generated method stub
+ JPanel parametrisation = new JPanel(new GridLayout(1,2));
+ add(parametrisation,BorderLayout.CENTER);
+
+ JPanel param = new JPanel(new BorderLayout());
+ parametrisation.add(param);
+
+ JLabel 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,0,200,100);
+ param.add(f, BorderLayout.CENTER);
+ f.addChangeListener(new ChangeListener() {
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ gCodeTransformer.setFValue((int)f.getValue());
+ }
+ });
+ f.setMajorTickSpacing(10);
+ f.setPaintTicks(true);
+ Hashtable labelTable = new Hashtable();
+ labelTable.put( new Integer( 0 ), new JLabel("0%") );
+ labelTable.put( new Integer( 100 ), new JLabel("100%") );
+ labelTable.put( new Integer( 200 ), new JLabel("200%") );
+ f.setLabelTable( labelTable );
+ f.setPaintLabels(true);
+
+ param = new JPanel(new BorderLayout());
+ parametrisation.add(param);
+
+ JLabel 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,0,200,100);
+ param.add(s);
+
+ s.addChangeListener(new ChangeListener() {
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ gCodeTransformer.setSValue((int)s.getValue());
+ }
+ });
+ s.setMajorTickSpacing(10);
+ s.setPaintTicks(true);
+ labelTable = new Hashtable<Integer, JLabel>();
+ labelTable.put( new Integer( 0 ), new JLabel("0%") );
+ labelTable.put( new Integer( 100 ), new JLabel("100%") );
+ labelTable.put( new Integer( 200 ), new JLabel("200%") );
+ s.setLabelTable( labelTable );
+ s.setPaintLabels(true);
}
Please sign in to comment.
Something went wrong with that request. Please try again.