Skip to content
Browse files

Added factor and scaling ScaleValuesTransformation

  • Loading branch information...
1 parent e2e126a commit 15bc9d18ae213a038b0bd19f7f899003396570cd @mnemonia committed Mar 12, 2012
View
10 ...andStudioGCodeTransformer/src/com/rocketbrandstudios/gcode/impl/GCodeTransformerImpl.java
@@ -8,8 +8,8 @@
public final class GCodeTransformerImpl implements GCodeTransformer {
private File in,out;
- private int fScaling;
- private int sScaling;
+ private int fScaling = 1;
+ private int sScaling = 1;
public GCodeTransformerImpl(){
in = new File("C:/in.gcode");
@@ -18,10 +18,10 @@ public GCodeTransformerImpl(){
@Override
public void go() {
-
+ System.out.println("GCodeTransformerImpl.go(fScaling:"+fScaling+", sScaling:"+sScaling+")");
new TransformerImpl(
- new ScaleValuesTransformation("F",60),
- new ScaleValuesTransformation("S",1)
+ new ScaleValuesTransformation("F",60,fScaling),
+ new ScaleValuesTransformation("S",1,sScaling)
).transform(in, out);
}
View
6 ...cketbrandstudios/gcode/service/transformer/transformations/ScaleValuesTransformation.java
@@ -9,8 +9,10 @@
public final class ScaleValuesTransformation implements Transformation {
private final String marker;
private final int scaling;
+ private final int factor;
- public ScaleValuesTransformation(String marker, int scaling) {
+ public ScaleValuesTransformation(String marker, int factor, int scaling) {
+ this.factor = factor;
this.scaling = scaling;
this.marker = marker;
}
@@ -30,7 +32,7 @@ public Lines transform(Lines in) {
if(v.startsWith(marker)){
v = v.substring(1,v.length());
double d = Double.parseDouble(v);
- d = scaling * d;
+ d = Math.round( 1.0/scaling * factor * d );
newLineBuffer.append(marker+d);
}else{
newLineBuffer.append(v);
View
8 ...etBrandStudioGCodeTransformer/src/com/rocketbrandstudios/gcode/ui/GCodeTransformerUI.java
@@ -59,7 +59,7 @@ private void addParametrisation() {
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);
+ final JSlider f = new JSlider(JSlider.VERTICAL,1,200,100);
param.add(f, BorderLayout.CENTER);
f.addChangeListener(new ChangeListener() {
@@ -71,7 +71,7 @@ public void stateChanged(ChangeEvent e) {
f.setMajorTickSpacing(10);
f.setPaintTicks(true);
Hashtable labelTable = new Hashtable();
- labelTable.put( new Integer( 0 ), new JLabel("0%") );
+ 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 );
@@ -83,7 +83,7 @@ public void stateChanged(ChangeEvent e) {
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);
+ final JSlider s = new JSlider(JSlider.VERTICAL,1,200,100);
param.add(s);
s.addChangeListener(new ChangeListener() {
@@ -96,7 +96,7 @@ public void stateChanged(ChangeEvent e) {
s.setMajorTickSpacing(10);
s.setPaintTicks(true);
labelTable = new Hashtable<Integer, JLabel>();
- labelTable.put( new Integer( 0 ), new JLabel("0%") );
+ labelTable.put( new Integer( 1 ), new JLabel("1%") );
labelTable.put( new Integer( 100 ), new JLabel("100%") );
labelTable.put( new Integer( 200 ), new JLabel("200%") );
s.setLabelTable( labelTable );

0 comments on commit 15bc9d1

Please sign in to comment.
Something went wrong with that request. Please try again.