2015-01-21 21:58:35 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2014, 2015 MINRES Technologies GmbH and others.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
|
|
|
*******************************************************************************/
|
2015-01-25 14:23:34 +01:00
|
|
|
package com.minres.scviewer.database.swt.internal;
|
2015-01-20 18:50:15 +01:00
|
|
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
import org.eclipse.swt.graphics.GC;
|
|
|
|
import org.eclipse.swt.graphics.Rectangle;
|
|
|
|
|
2015-01-25 14:23:34 +01:00
|
|
|
public class TrackPainter implements IPainter {
|
2015-01-20 18:50:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private final WaveformCanvas waveCanvas;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param txDisplay
|
|
|
|
*/
|
2015-01-25 14:23:34 +01:00
|
|
|
public TrackPainter(WaveformCanvas waveCanvas) {
|
2015-01-20 18:50:15 +01:00
|
|
|
this.waveCanvas = waveCanvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void paintArea(GC gc, Rectangle area) {
|
|
|
|
if(this.waveCanvas.streams.size()>0){
|
|
|
|
Integer firstKey=this.waveCanvas.trackVerticalOffset.floorKey(area.y);
|
|
|
|
if(firstKey==null) firstKey=this.waveCanvas.trackVerticalOffset.firstKey();
|
|
|
|
Integer lastKey = this.waveCanvas.trackVerticalOffset.floorKey(area.y+area.height);
|
|
|
|
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
|
|
|
|
if(lastKey==firstKey){
|
|
|
|
subArea.y=firstKey;
|
|
|
|
IWaveformPainter p = this.waveCanvas.trackVerticalOffset.get(firstKey);
|
|
|
|
subArea.height=p.getMinHeight();
|
|
|
|
p.paintArea(gc, subArea);
|
|
|
|
}else{
|
|
|
|
for(Entry<Integer, IWaveformPainter> entry : this.waveCanvas.trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
|
|
|
|
subArea.y=entry.getKey();
|
|
|
|
subArea.height=entry.getValue().getMinHeight();
|
|
|
|
entry.getValue().paintArea(gc, subArea);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|