// Path: src/main/java/waveview/wavedata/NetDataModel.java
// public final class NetDataModel {
//     private final String shortName;
//     private final String fullName;
//     private TransitionVector transitionVector;
//     private final String decoderName;
//     private final String[] decoderInputNets;
//     private String[] decoderParameters;
// 
//     public NetDataModel(String shortName, String fullName,
//             TransitionVector transitionVector) {
//         this.shortName = shortName;
//         this.fullName = fullName;
//         this.transitionVector = transitionVector;
//         decoderName = "";
//         decoderInputNets = new String[0];
//     }
// 
//     public NetDataModel(String shortName, String fullName,
//             String decoderName, String[] decoderInputNets,
//             String[] decoderParameters,
//             TransitionVector transitionVector) {
//         this.shortName = shortName;
//         this.fullName = fullName;
//         this.transitionVector = transitionVector;
//         this.decoderName = decoderName;
//         this.decoderParameters = decoderParameters.clone();
//         this.decoderInputNets = decoderInputNets.clone();
//     }
// 
//     public String getFullName() {
//         return fullName;
//     }
// 
//     public String getShortName() {
//         return shortName;
//     }
// 
//     public String getDecoderName() {
//         return decoderName;
//     }
// 
//     public String[] getDecoderInputNets() {
//         return decoderInputNets.clone();
//     }
// 
//     public String[] getDecoderParams() {
//         return decoderParameters.clone();
//     }
// 
//     public TransitionVector getTransitionVector() {
//         return transitionVector;
//     }
// 
//     public void setTransitionVector(TransitionVector transitionVector) {
//         this.transitionVector = transitionVector;
//     }
// 
//     public Iterator<Transition> findTransition(long timestamp) {
//         return transitionVector.findTransition(timestamp);
//     }
// 
//     public long getMaxTimestamp() {
//         return transitionVector.getMaxTimestamp();
//     }
// 
//     public int getWidth() {
//         return transitionVector.getWidth();
//     }
// }
// 
// Path: src/main/java/waveview/wavedata/SortedArrayList.java
// public final class SortedArrayList<T extends SortedArrayList.Keyed> {
//     private final List<T> list = new ArrayList<>();
// 
//     public interface Keyed { long getKey(); }
// 
//     public int size() {
//         return list.size();
//     }
// 
//     public void clear() {
//         list.clear();
//     }
// 
//     public T get(int index) {
//         return list.get(index);
//     }
// 
//     public void remove(int index) {
//         list.remove(index);
//     }
// 
//     public boolean add(T value) {
//         long key = ((Keyed) value).getKey();
//         for (int i = 0;; i++) {
//             if (i == size() || ((Keyed) get(i)).getKey() > key) {
//                 list.add(i, value);
//                 break;
//             }
//         }
// 
//         return true;
//     }
// 
//     public Iterator<T> find(long key) {
//         return new SortedArrayListIterator(findIndex(key));
//     }
// 
//     /// @param key key value to search for
//     /// @returns index into array of element that matches key. If an
//     /// element isn't at this timestamp, return the element before the
//     /// timestamp. If the key is before the first element, return 0.
//     public int findIndex(long key) {
//         // Binary search
//         int low = 0; // Lowest possible index
//         int high = size() - 1; // Highest possible index
// 
//         while (low <= high) {
//             int mid = (low + high) >>> 1;
//             long midKey = ((Keyed) get(mid)).getKey();
//             if (key < midKey) {
//                 high = mid - 1;
//             } else if (key > midKey) {
//                 low = mid + 1;
//             } else {
//                 return mid;
//             }
//         }
// 
//         // No exact match. Low is equal to the index the transition would be
//         // at if it existed. We want to return the transition before the
//         // timestamp. If low == 0, this is before the first transition:
//         // return 0.
//         if (low == 0) {
//             return 0;
//         }
// 
//         return low - 1;
//     }
// 
//     private class SortedArrayListIterator implements Iterator<T> {
//         private int index;
// 
//         SortedArrayListIterator(int index) {
//             this.index = index;
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return index < SortedArrayList.this.size();
//         }
// 
//         @Override
//         public T next() {
//             if (!hasNext()) {
//                 throw new NoSuchElementException();
//             }
// 
//             T val = SortedArrayList.this.get(index);
//             index++;
//             return val;
//         }
// 
//         @Override
//         public void remove() {
//             throw new UnsupportedOperationException();
//         }
//     }
// }


import java.util.ArrayList;
import java.util.List;
import waveview.wavedata.NetDataModel;
import waveview.wavedata.SortedArrayList;
//
// Copyright 2011-2012 Jeff Bush
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package waveview;


///
/// Contains visible state for a waveform capture (e.g. Cursor position, scale,
/// visible nets, etc.)
///
public final class WaveformPresentationModel {
    private final List<Listener> listeners = new ArrayList<>();
    private final List<NetPresentationModel> visibleNets = new ArrayList<>();
    private final List<NetSet> netSets = new ArrayList<>();
    private long cursorPosition;
    private long selectionStart;
    private double horizontalScale; // Pixels per time units
    private boolean adjustingCursor;
// Path: src/main/java/waveview/wavedata/NetDataModel.java
// public final class NetDataModel {
//     private final String shortName;
//     private final String fullName;
//     private TransitionVector transitionVector;
//     private final String decoderName;
//     private final String[] decoderInputNets;
//     private String[] decoderParameters;
// 
//     public NetDataModel(String shortName, String fullName,
//             TransitionVector transitionVector) {
//         this.shortName = shortName;
//         this.fullName = fullName;
//         this.transitionVector = transitionVector;
//         decoderName = "";
//         decoderInputNets = new String[0];
//     }
// 
//     public NetDataModel(String shortName, String fullName,
//             String decoderName, String[] decoderInputNets,
//             String[] decoderParameters,
//             TransitionVector transitionVector) {
//         this.shortName = shortName;
//         this.fullName = fullName;
//         this.transitionVector = transitionVector;
//         this.decoderName = decoderName;
//         this.decoderParameters = decoderParameters.clone();
//         this.decoderInputNets = decoderInputNets.clone();
//     }
// 
//     public String getFullName() {
//         return fullName;
//     }
// 
//     public String getShortName() {
//         return shortName;
//     }
// 
//     public String getDecoderName() {
//         return decoderName;
//     }
// 
//     public String[] getDecoderInputNets() {
//         return decoderInputNets.clone();
//     }
// 
//     public String[] getDecoderParams() {
//         return decoderParameters.clone();
//     }
// 
//     public TransitionVector getTransitionVector() {
//         return transitionVector;
//     }
// 
//     public void setTransitionVector(TransitionVector transitionVector) {
//         this.transitionVector = transitionVector;
//     }
// 
//     public Iterator<Transition> findTransition(long timestamp) {
//         return transitionVector.findTransition(timestamp);
//     }
// 
//     public long getMaxTimestamp() {
//         return transitionVector.getMaxTimestamp();
//     }
// 
//     public int getWidth() {
//         return transitionVector.getWidth();
//     }
// }
// 
// Path: src/main/java/waveview/wavedata/SortedArrayList.java
// public final class SortedArrayList<T extends SortedArrayList.Keyed> {
//     private final List<T> list = new ArrayList<>();
// 
//     public interface Keyed { long getKey(); }
// 
//     public int size() {
//         return list.size();
//     }
// 
//     public void clear() {
//         list.clear();
//     }
// 
//     public T get(int index) {
//         return list.get(index);
//     }
// 
//     public void remove(int index) {
//         list.remove(index);
//     }
// 
//     public boolean add(T value) {
//         long key = ((Keyed) value).getKey();
//         for (int i = 0;; i++) {
//             if (i == size() || ((Keyed) get(i)).getKey() > key) {
//                 list.add(i, value);
//                 break;
//             }
//         }
// 
//         return true;
//     }
// 
//     public Iterator<T> find(long key) {
//         return new SortedArrayListIterator(findIndex(key));
//     }
// 
//     /// @param key key value to search for
//     /// @returns index into array of element that matches key. If an
//     /// element isn't at this timestamp, return the element before the
//     /// timestamp. If the key is before the first element, return 0.
//     public int findIndex(long key) {
//         // Binary search
//         int low = 0; // Lowest possible index
//         int high = size() - 1; // Highest possible index
// 
//         while (low <= high) {
//             int mid = (low + high) >>> 1;
//             long midKey = ((Keyed) get(mid)).getKey();
//             if (key < midKey) {
//                 high = mid - 1;
//             } else if (key > midKey) {
//                 low = mid + 1;
//             } else {
//                 return mid;
//             }
//         }
// 
//         // No exact match. Low is equal to the index the transition would be
//         // at if it existed. We want to return the transition before the
//         // timestamp. If low == 0, this is before the first transition:
//         // return 0.
//         if (low == 0) {
//             return 0;
//         }
// 
//         return low - 1;
//     }
// 
//     private class SortedArrayListIterator implements Iterator<T> {
//         private int index;
// 
//         SortedArrayListIterator(int index) {
//             this.index = index;
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return index < SortedArrayList.this.size();
//         }
// 
//         @Override
//         public T next() {
//             if (!hasNext()) {
//                 throw new NoSuchElementException();
//             }
// 
//             T val = SortedArrayList.this.get(index);
//             index++;
//             return val;
//         }
// 
//         @Override
//         public void remove() {
//             throw new UnsupportedOperationException();
//         }
//     }
// }


// Path: src/main/java/waveview/WaveformPresentationModel.java
import java.util.ArrayList;
import java.util.List;
import waveview.wavedata.NetDataModel;
import waveview.wavedata.SortedArrayList;

//
// Copyright 2011-2012 Jeff Bush
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package waveview;


///
/// Contains visible state for a waveform capture (e.g. Cursor position, scale,
/// visible nets, etc.)
///
public final class WaveformPresentationModel {
    private final List<Listener> listeners = new ArrayList<>();
    private final List<NetPresentationModel> visibleNets = new ArrayList<>();
    private final List<NetSet> netSets = new ArrayList<>();
    private long cursorPosition;
    private long selectionStart;
    private double horizontalScale; // Pixels per time units
    private boolean adjustingCursor;
    private final SortedArrayList<Marker> markers = new SortedArrayList<>();