Class ScaleMusicShapeEditorOperator

  extended by com.softsynth.jmsl.util.ScaleMusicShapeEditorOperator
All Implemented Interfaces:
Namable, MusicShapeEditorOperator

public class ScaleMusicShapeEditorOperator
extends java.lang.Object
implements MusicShapeEditorOperator

transpose and scale selected range of MusicShape by (v2 / v3) or (v3 / v2)

Nick Didkovsky,

Constructor Summary
ScaleMusicShapeEditorOperator(boolean flip)
Method Summary
 java.lang.String getName()
 void operate(MusicShapeEditor se, MusicShape s)
          scale by v2 / v3 or v3 / v2 depending on boolean flip value No scaling if denom==0
 void setName(java.lang.String n)
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ScaleMusicShapeEditorOperator(boolean flip)
Method Detail


public void operate(MusicShapeEditor se,
                    MusicShape s)
scale by v2 / v3 or v3 / v2 depending on boolean flip value No scaling if denom==0
        if (se.getRangeStartIndex() != -1 && se.getRangeEndIndex() != -1
                && Limits.within(se.getDimension(), 0, s.dimension() - 1)) {
            double numer = se.getV2();
            double denom = se.getV3();
            double scaler = 1;
            if (flip && numer != 0) {
                scaler = denom / numer;
            } else if (!flip && denom != 0) {
                scaler = numer / denom;
            s.scale(scaler, se.getRangeStartIndex(), se.getRangeEndIndex(), se.getDimension());

Specified by:
operate in interface MusicShapeEditorOperator


public java.lang.String getName()
Specified by:
getName in interface Namable


public void setName(java.lang.String n)
Specified by:
setName in interface Namable