Class MusicShape

java.lang.Object
com.softsynth.jmsl.MusicJob
com.softsynth.jmsl.MusicShape
All Implemented Interfaces:
Composable, DimensionNameSpace, Playable, java.lang.Cloneable, java.lang.Runnable
Direct Known Subclasses:
MidiNoteRecorder, SabbathBrideMusicShape

public class MusicShape
extends MusicJob
implements java.lang.Cloneable, DimensionNameSpace
MusicShape - a MusicJob with an abstract array of data elements. Each data element is an array of doubles. A MusicShape has any number of elements. Each element has the same number of dimensions 0..n, which can be named with human-friendly monikers (such as "duration", "pitch", "loudness"...).

A MusicShape's Instrument is handed one element at a time. The interpretation of this element depends on the Instrument's Interpreter, which reads the array of doubles in a consistent way and generates some kind of meaningful event with it (ie sounding a MIDI note, doing some drawing, etc)

MusicShape is Composable, so it can be put in a JMSL hierarchy and launched.

Author:
Phil Burk and Nick Didkovsky
  • Field Summary

    Fields inherited from class com.softsynth.jmsl.MusicJob

    repeatCount
  • Constructor Summary

    Constructors
    Constructor Description
    MusicShape​(int dimensions)
    construct a new MusicShape with a Printing Instrument
    MusicShape​(DimensionNameSpace dimensionNameSpace)
    construct a new MusicShape with same number of dimensions, names, and limits as source
    MusicShape​(Instrument ins, int dimensions)  
  • Method Summary

    Modifier and Type Method Description
    void add​(double d0)
    Add element with 1 dimension
    void add​(double[] d)
    Add an element to this MusicShape.
    void add​(double d0, double d1)
    Add element with 2 dimensions
    void add​(double d0, double d1, double d2)
    Add element with 3 dimensions
    void add​(double d0, double d1, double d2, double d3)
    Add element with 4 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4)
    Add element with 5 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5)
    Add element with 6 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6)
    Add element with 7 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7)
    Add element with 8 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8)
    Add element with 9 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9)
    Add element with 10 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
    Add element with 11 dimensions
    void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10, double d11)
    Add element with 12 dimensions
    void calcDimStats​(int dim)
    called automatically by calcStats(), calculates statistics for specified dimension
    void calcStats()
    called automatically by print(), calculates statistics for each dimension
    double clipValDim​(double value, int dim)
    return value clipped to dimension's limits
    java.lang.Object clone()
    Clones contents of shape.
    void convertTimeBaseDim​(double srcTicksPerSec, double destTicksPerSec, int dim)
    (srcTicksPerSec, destTicksPerSec, dim), recalculate all durations in specified dimension
    void copyDataFrom​(MusicShape source)
    Exact duplicate of double[] elements from source MusicShape to this MusicShape.
    void copyDataFrom​(java.util.Vector source)
    Copy double[] elements from source Vector of double[] to this MusicShape.
    void copyDimensionNameSpace​(DimensionNameSpace source)
    Copy dimension names, limits and defaults from source DimensionNameSpace to this MusicShape
    void differentiate​(double sum, int dim)
    go from absolute to delta time, given sum and dimension.
    int dimension()
    returns how many dimensions a MusicShape has
    java.util.Enumeration dimensionNames()  
    java.lang.String dumpSource()
    Generate Java source that would recreate this MusicShape
    void dumpSource​(java.io.PrintWriter pout)
    Generate Java source that would recreate this MusicShape, write to a PrintWriter
    void dumpSource​(java.lang.String filename)
    Generate Java source that would recreate this MusicShape, write to a file
    void fill​(double value, int start, int end, int dimension)
    Set all values in specified range to specified value along specified dimension.
    void finishAll()
    Doesn't contain Composable, so cannot propagate finishAll() to children, just calls finish() on itself instead
    double[] get​(int i)  
    double get​(int e, int d)
    returns the value at element i, dimension d
    java.util.Vector getData()  
    double getDefault​(int dim)  
    double[] getDefaultArray()  
    static double[] getDefaultArray​(DimensionNameSpace dns)  
    int getDimension​(java.lang.String name)  
    java.lang.String getDimensionName​(int dim)  
    java.lang.String getDimName​(int dim)
    Deprecated.
    use getDimensionName(int dim), which is part of interface DimensionNameSpace
    double getHighLimit​(int dim)
    return highest allowable value for specified dimension
    int getInt​(int e, int d)
    same as get(), cast to an int
    double getLowLimit​(int dim)
    return lowest allowable value for specified dimension
    double getMax​(int dim)
    return precalculated maximum value found (calculated by calcStats())
    double getMean​(int dim)
    return precalculated mean (calculated by calcStats())
    double getMin​(int dim)
    return precalculated minimim value found (calculated by calcStats())
    int getNumberOfNames()  
    double getSum​(int dim)
    return precalulated sum (calculated by calcStats())
    void insert​(double[] dar, int index)
    Behaves just like Vector.insertElementAt().
    double integrate​(int dim)
    go from delta time to absolute time on specified dimension (typically 0)
    double internalRepeat​(double playTime)
    Execute all elements in shape if an instrument is plugged in.
    void invert​(double val, int start, int end, int dim)
    invert Shape data about a "horizontal line" .
    static boolean isClippingEnabled()  
    boolean isConstrainedToLimits()
    When elements are add()'ed constrain them to the limits of the dimensions or not
    boolean isSafeOrdering()
    safe ordering flags whether or not to swap start and end arguments if end lessthan start, in methods that use them, like scramble(), reverse(), sort(), etc
    void load​(java.io.BufferedReader in)
    BufferedReader in = new BufferedReader(new FileReader("foo.in")); Replace data with data loaded from a file.
    static void main​(java.lang.String[] args)
    exercise shape building and manipulation
    void prefab()
    Same as prefab(17)
    void prefab​(int numElements)
    Generate random data with first four dimensions interpreted as duration, pitch, amplitude, and hold time.
    void print()
    Calls calcStats() to generate statistics, then prints out MusicShape data to JMSL.out
    void printDim​(int i)  
    void printDimNames()
    print all names for all dimensions
    void printStats()
    print statistics to JMSL.out
    static int qa()
    Quality Assurance
    void randomize​(double min, double max, int start, int end, int dim)
    set random values into a shape.
    static MusicShape readBinaryHMSLShape​(java.io.DataInputStream in)
    Read a binary file into a new Shape.
    void remove​(int index)
    Remove child at specified index
    void remove​(int fromIndex, int toIndex)
    Removes from this MusicShape all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
    void reverse​(int start, int end, int dim)
    reverse the order of Shape data.
    void save​(java.io.PrintWriter out)
    Save a MusicShape to a file PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); First line is number of dimensions, followed by dimension names, one per line, followed by data, one element per line *
    void scale​(double scalar, int start, int end, int dim)
    multiply each value by a scalar .
    void scramble​(int start, int end, int dim)
    randomly reorder data in range.
    void set​(double[] dar, int e)
    Replace element at position e with double[].
    void set​(double value, int e, int d)
    set(value, elem#, dim#) replace old value at (elem, dim) with new value
    void set​(int value, int e, int d)  
    void set​(long value, int e, int d)  
    void setClipped​(double value, int e, int d)
    safer version of set, automatically clips to dimension's limits, if !isClippingEnabled, just passes value through.
    static void setClippingEnabled​(boolean clippingEnabled)  
    void setConstrainedToLimits​(boolean constrainedToLimits)
    When elements are add()'ed constrain them to the limits of the dimensions or not *
    void setDefault​(int dim, double value)
    Set a default value for a dimension
    void setDimensionName​(int dim, java.lang.String name)
    assign a name to a dimension.
    void setDimName​(int dim, java.lang.String name)
    Give a custom name to a dimension, ex setDimName(3, "Duration")
    void setDimName​(java.lang.String name, int dim)
    Give a custom name to a dimension, ex setDimName("Duration", 3)
    void setLimits​(int dim, double low, double high)
    set the lowest and highest limits for a dimension, used by clipping
    void setSafeOrdering​(boolean b)  
    void sort()
    Sort shape on dim 0
    void sort​(int dim)
    Sort shape in ascending values along specified dim
    void sort​(int start, int end, int dim)
    Sort shape in ascending values along specified dim
    void sort​(int start, int end, int dim, DimensionComparison cf)
    sorts using user defined DimensionComparison function.
    double start​(double startTime)
    open() Instrument and return startTime
    boolean statsCalculated()
    returns whether or not stats have been calculated
    double stop​(double stopTime)
    close() Instrument and return stopTime
    void sumSet​(double value, int e, int d)
    add double value to value in shape, like +=
    void sumSet​(int value, int e, int d)
    add int value to value in shape, like +=
    void swap​(int elm1, int elm2, int dim)
    swap data, dim <0 signals swap entire element, otherwise swap in specified dim only
    java.lang.String toString()  
    MusicShape translate​(DimensionNameSpace destinationNameSpace)
    Create a new MusicShape populated with this MusicShape's data, after translating from this MusicShape's DimensionNameSpace to another
    void transpose​(double val, int start, int end, int dim)
    add val to a range of Shape data, clip to dim limits .
    boolean usesStandardInvariants()  
    void useStandardDimensionNameSpace()
    renames dimension 0..3 as duration, pitch, amplitude, hold with default values and limits.
    void useStandardInvariants​(boolean f)
    If this flag is set, and if the DimensionNameSpace of the instrument != null, then Dimensions 0..3 will be set as DimensionnameSpace invariants.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MusicShape

      public MusicShape​(DimensionNameSpace dimensionNameSpace)
      construct a new MusicShape with same number of dimensions, names, and limits as source
    • MusicShape

      public MusicShape​(int dimensions)
      construct a new MusicShape with a Printing Instrument
    • MusicShape

      public MusicShape​(Instrument ins, int dimensions)
  • Method Details

    • getData

      public java.util.Vector getData()
      Returns:
      vector of raw double[] elements
    • useStandardInvariants

      public void useStandardInvariants​(boolean f)
      If this flag is set, and if the DimensionNameSpace of the instrument != null, then Dimensions 0..3 will be set as DimensionnameSpace invariants. This means that regardless of dimension names, dimension 0 of MusicShape will copy to dimension 0 of double[] handed to instrument, same for dims 1, 2, 3 This protects a standard interpretation where dim 0 = duration, dim 1 = pitch, dim 2 = amplitude, dim 3 = hold time in seconds. Defaults to true.
    • usesStandardInvariants

      public boolean usesStandardInvariants()
    • useStandardDimensionNameSpace

      public void useStandardDimensionNameSpace()
      renames dimension 0..3 as duration, pitch, amplitude, hold with default values and limits. If dimensions >= 4 are unaffected
    • getDefaultArray

      public double[] getDefaultArray()
      Returns:
      array containing default values for each dimension in this MusicShape's DimensionNameSpace
    • getDefaultArray

      public static double[] getDefaultArray​(DimensionNameSpace dns)
      Returns:
      array containing default values for each dimension in DimensionNameSpace arg
    • copyDataFrom

      public void copyDataFrom​(MusicShape source)
      Exact duplicate of double[] elements from source MusicShape to this MusicShape. Each double[] from the source is copied to a new double[] array before adding. safe.
    • copyDataFrom

      public void copyDataFrom​(java.util.Vector source)
      Copy double[] elements from source Vector of double[] to this MusicShape. Each double[] from the source is copied to a new double[] array before adding. safe.
    • dimension

      public int dimension()
      returns how many dimensions a MusicShape has
      Specified by:
      dimension in interface DimensionNameSpace
      Returns:
      number of dimensions. Useful if you are allocating an array for example
    • set

      public void set​(double[] dar, int e)
      Replace element at position e with double[]. Makes a copy of array before inserting it.
    • set

      public void set​(double value, int e, int d)
      set(value, elem#, dim#) replace old value at (elem, dim) with new value
    • set

      public void set​(int value, int e, int d)
    • set

      public void set​(long value, int e, int d)
    • fill

      public void fill​(double value, int start, int end, int dimension)
      Set all values in specified range to specified value along specified dimension. Range includes end.
    • sumSet

      public void sumSet​(int value, int e, int d)
      add int value to value in shape, like +=
    • sumSet

      public void sumSet​(double value, int e, int d)
      add double value to value in shape, like +=
    • setDimName

      public void setDimName​(java.lang.String name, int dim)
      Give a custom name to a dimension, ex setDimName("Duration", 3)
    • setDimName

      public void setDimName​(int dim, java.lang.String name)
      Give a custom name to a dimension, ex setDimName(3, "Duration")
    • insert

      public void insert​(double[] dar, int index)
      Behaves just like Vector.insertElementAt(). Elements with index >= index get pushed up
    • remove

      public void remove​(int index)
      Description copied from class: MusicJob
      Remove child at specified index
      Overrides:
      remove in class MusicJob
    • remove

      public void remove​(int fromIndex, int toIndex)
      Removes from this MusicShape all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. if fromIndex == toIndex, there is no effect
    • add

      public void add​(double[] d)
      Add an element to this MusicShape. Element is a double[]. The array itself (not a copy) is added
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10, double d11)
      Add element with 12 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
      Add element with 11 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9)
      Add element with 10 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8)
      Add element with 9 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7)
      Add element with 8 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5, double d6)
      Add element with 7 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4, double d5)
      Add element with 6 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3, double d4)
      Add element with 5 dimensions
    • add

      public void add​(double d0, double d1, double d2, double d3)
      Add element with 4 dimensions
    • add

      public void add​(double d0, double d1, double d2)
      Add element with 3 dimensions
    • add

      public void add​(double d0, double d1)
      Add element with 2 dimensions
    • add

      public void add​(double d0)
      Add element with 1 dimension
    • copyDimensionNameSpace

      public void copyDimensionNameSpace​(DimensionNameSpace source)
      Copy dimension names, limits and defaults from source DimensionNameSpace to this MusicShape
    • getNumberOfNames

      public int getNumberOfNames()
      Specified by:
      getNumberOfNames in interface DimensionNameSpace
      Returns:
      number of names stored in name space. Not the same as highest dimension. Not all dimensions require names.
    • getDimensionName

      public java.lang.String getDimensionName​(int dim)
      Specified by:
      getDimensionName in interface DimensionNameSpace
      Returns:
      name of specified dimension, or null if dim out of bounds
    • getDimension

      public int getDimension​(java.lang.String name)
      Specified by:
      getDimension in interface DimensionNameSpace
      Returns:
      dimension associated with name or -1 if no dimension found for that name
    • setDimensionName

      public void setDimensionName​(int dim, java.lang.String name)
      assign a name to a dimension. dim must be < dimension()
      Specified by:
      setDimensionName in interface DimensionNameSpace
    • setDefault

      public void setDefault​(int dim, double value)
      Set a default value for a dimension
      Specified by:
      setDefault in interface DimensionNameSpace
    • getDefault

      public double getDefault​(int dim)
      Specified by:
      getDefault in interface DimensionNameSpace
      Returns:
      default value associated with this dimension, or Double.NEGATIVE_INFINITY if dim out of range
    • dimensionNames

      public java.util.Enumeration dimensionNames()
      Specified by:
      dimensionNames in interface DimensionNameSpace
    • translate

      public MusicShape translate​(DimensionNameSpace destinationNameSpace)
      Create a new MusicShape populated with this MusicShape's data, after translating from this MusicShape's DimensionNameSpace to another
    • getDimName

      public java.lang.String getDimName​(int dim)
      Deprecated.
      use getDimensionName(int dim), which is part of interface DimensionNameSpace
      return name for dimension d
    • get

      public double[] get​(int i)
      Returns:
      copy of the array of double at position i. IMPORTANT! This is a COPY of the array!!!
    • get

      public double get​(int e, int d)
      returns the value at element i, dimension d
    • getInt

      public int getInt​(int e, int d)
      same as get(), cast to an int
    • getMin

      public double getMin​(int dim)
      return precalculated minimim value found (calculated by calcStats())
    • getMean

      public double getMean​(int dim)
      return precalculated mean (calculated by calcStats())
    • getMax

      public double getMax​(int dim)
      return precalculated maximum value found (calculated by calcStats())
    • getSum

      public double getSum​(int dim)
      return precalulated sum (calculated by calcStats())
    • getLowLimit

      public double getLowLimit​(int dim)
      return lowest allowable value for specified dimension
      Specified by:
      getLowLimit in interface DimensionNameSpace
      Returns:
      lowest allowable value for specified dimension
    • getHighLimit

      public double getHighLimit​(int dim)
      return highest allowable value for specified dimension
      Specified by:
      getHighLimit in interface DimensionNameSpace
      Returns:
      highest allowable value for specified dimension
    • setLimits

      public void setLimits​(int dim, double low, double high)
      set the lowest and highest limits for a dimension, used by clipping
      Specified by:
      setLimits in interface DimensionNameSpace
    • calcDimStats

      public void calcDimStats​(int dim)
      called automatically by calcStats(), calculates statistics for specified dimension
    • calcStats

      public void calcStats()
      called automatically by print(), calculates statistics for each dimension
    • statsCalculated

      public boolean statsCalculated()
      returns whether or not stats have been calculated
    • isClippingEnabled

      public static boolean isClippingEnabled()
      Returns:
      Returns the clippingEnabled flag.
    • setClippingEnabled

      public static void setClippingEnabled​(boolean clippingEnabled)
      Parameters:
      clippingEnabled - The clippingEnabled to set.
    • setClipped

      public void setClipped​(double value, int e, int d)
      safer version of set, automatically clips to dimension's limits, if !isClippingEnabled, just passes value through.
    • clipValDim

      public double clipValDim​(double value, int dim)
      return value clipped to dimension's limits
    • convertTimeBaseDim

      public void convertTimeBaseDim​(double srcTicksPerSec, double destTicksPerSec, int dim)
      (srcTicksPerSec, destTicksPerSec, dim), recalculate all durations in specified dimension
    • integrate

      public double integrate​(int dim)
      go from delta time to absolute time on specified dimension (typically 0)
    • differentiate

      public void differentiate​(double sum, int dim)
      go from absolute to delta time, given sum and dimension. Sum is total duration of MusicShape (for example, the absolute time of the last element plus its hold time). dim is typically 0.
                   
                    
                     
                      
                       
                        
                         
                          
                                      Durations before (absolute time):
                                      0 
                                      1
                                      2
                                      3
                                      3.5
                                      
                                      Durations after (delta time, assume sum passed in = 5):
                                      1
                                      1
                                      1
                                      0.5
                                      1.5
       
       
       
       
       
       
       
       
    • randomize

      public void randomize​(double min, double max, int start, int end, int dim)
      set random values into a shape. Random chosen between min and max for specified dimension. Range includes end.
    • transpose

      public void transpose​(double val, int start, int end, int dim)
      add val to a range of Shape data, clip to dim limits . Range includes end.
    • scale

      public void scale​(double scalar, int start, int end, int dim)
      multiply each value by a scalar . Range includes end.
    • invert

      public void invert​(double val, int start, int end, int dim)
      invert Shape data about a "horizontal line" . Range includes end.
    • reverse

      public void reverse​(int start, int end, int dim)
      reverse the order of Shape data. A negative dimension signals that all dimensions should be reversed. Range includes end.
    • swap

      public void swap​(int elm1, int elm2, int dim)
      swap data, dim <0 signals swap entire element, otherwise swap in specified dim only
    • scramble

      public void scramble​(int start, int end, int dim)
      randomly reorder data in range. dim < 0 signals swap entire element. Range includes end.
    • sort

      public void sort​(int start, int end, int dim, DimensionComparison cf)
      sorts using user defined DimensionComparison function. You could ignore dim in your DimensionComparison function and do comparisions that involve more than one dimension
    • sort

      public void sort​(int dim)
      Sort shape in ascending values along specified dim
    • sort

      public void sort​(int start, int end, int dim)
      Sort shape in ascending values along specified dim
    • sort

      public void sort()
      Sort shape on dim 0
    • printDimNames

      public void printDimNames()
      print all names for all dimensions
    • printStats

      public void printStats()
      print statistics to JMSL.out
    • printDim

      public void printDim​(int i)
    • print

      public void print()
      Calls calcStats() to generate statistics, then prints out MusicShape data to JMSL.out
      Overrides:
      print in class MusicJob
    • dumpSource

      public void dumpSource​(java.lang.String filename) throws java.io.IOException
      Generate Java source that would recreate this MusicShape, write to a file
      Throws:
      java.io.IOException
    • dumpSource

      public void dumpSource​(java.io.PrintWriter pout) throws java.io.IOException
      Generate Java source that would recreate this MusicShape, write to a PrintWriter
      Throws:
      java.io.IOException
    • dumpSource

      public java.lang.String dumpSource()
      Generate Java source that would recreate this MusicShape
      Returns:
      String of source code
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • start

      public double start​(double startTime) throws java.lang.InterruptedException
      open() Instrument and return startTime
      Specified by:
      start in interface Composable
      Overrides:
      start in class MusicJob
      Returns:
      endTime
      Throws:
      java.lang.InterruptedException - thrown if Thread.interrupt() called.
    • stop

      public double stop​(double stopTime) throws java.lang.InterruptedException
      close() Instrument and return stopTime
      Specified by:
      stop in interface Composable
      Overrides:
      stop in class MusicJob
      Returns:
      endTime
      Throws:
      java.lang.InterruptedException - thrown if Thread.interrupt() called.
    • finishAll

      public void finishAll()
      Doesn't contain Composable, so cannot propagate finishAll() to children, just calls finish() on itself instead
      Specified by:
      finishAll in interface Composable
      Overrides:
      finishAll in class MusicJob
    • internalRepeat

      public double internalRepeat​(double playTime) throws java.lang.InterruptedException
      Execute all elements in shape if an instrument is plugged in.
      Specified by:
      internalRepeat in interface Composable
      Overrides:
      internalRepeat in class MusicJob
      Returns:
      stopTime
      Throws:
      java.lang.InterruptedException - thrown if Thread.interrupt() called.
    • prefab

      public void prefab()
      Same as prefab(17)
    • prefab

      public void prefab​(int numElements)
      Generate random data with first four dimensions interpreted as duration, pitch, amplitude, and hold time. Use a RandomWalk for pitch For dimensions > 3 randomize a value between getLowLimit() and getHighLimit() for that dimension
    • clone

      public java.lang.Object clone()
      Clones contents of shape. Makes copy of data in shape so that original can be modified without affecting clone, and vice versa.
    • qa

      public static int qa()
      Quality Assurance
    • readBinaryHMSLShape

      public static MusicShape readBinaryHMSLShape​(java.io.DataInputStream in) throws java.io.IOException
      Read a binary file into a new Shape. Useful for reading old HMSL Shapes into JMSL.
      File format is simply: #els, #dims, width (not supported), data
      Throws:
      java.io.IOException
    • save

      public void save​(java.io.PrintWriter out) throws java.io.IOException
      Save a MusicShape to a file PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); First line is number of dimensions, followed by dimension names, one per line, followed by data, one element per line *
      Throws:
      java.io.IOException
    • load

      public void load​(java.io.BufferedReader in) throws java.io.IOException
      BufferedReader in = new BufferedReader(new FileReader("foo.in")); Replace data with data loaded from a file. Also reads dimension names from file.
      Throws:
      java.io.IOException
    • main

      public static void main​(java.lang.String[] args)
      exercise shape building and manipulation
    • isSafeOrdering

      public boolean isSafeOrdering()
      safe ordering flags whether or not to swap start and end arguments if end lessthan start, in methods that use them, like scramble(), reverse(), sort(), etc
      Returns:
    • setSafeOrdering

      public void setSafeOrdering​(boolean b)
      Parameters:
      b -
    • isConstrainedToLimits

      public boolean isConstrainedToLimits()
      When elements are add()'ed constrain them to the limits of the dimensions or not
      Returns:
      Returns the constrainedToLimits.
    • setConstrainedToLimits

      public void setConstrainedToLimits​(boolean constrainedToLimits)
      When elements are add()'ed constrain them to the limits of the dimensions or not *
      Parameters:
      constrainedToLimits - The constrainedToLimits to set.