1
package org.herac.tuxguitar.gui.editors.tab;
3
import org.eclipse.swt.graphics.Color;
4
import org.eclipse.swt.graphics.Device;
5
import org.eclipse.swt.graphics.Image;
6
import org.herac.tuxguitar.gui.editors.TGPainter;
8
public class TGMeasureBuffer {
10
private Device device;
14
private TGPainter painter;
20
public TGMeasureBuffer(Device device){
24
public void makeBuffer(int width,int height,Color background){
26
this.buffer = new Image(this.device,width,height);
29
this.fillBuffer(background);
32
private void fillBuffer(Color background){
33
getPainter().setBackground(background);
34
getPainter().initPath(TGPainter.PATH_FILL);
35
getPainter().addRectangle(0,0,this.width,this.height);
36
getPainter().closePath();
39
public TGPainter getPainter(){
40
if(this.painter == null || this.painter.getGC().isDisposed()){
41
this.painter = new TGPainter(this.buffer);
46
public void paintImage(TGPainter painter,int x,int y,int srcY){
47
painter.drawImage(this.buffer,0,srcY, this.width, (this.height - srcY), x, (y + srcY), this.width, (this.height - srcY));
50
public Image getImage(){
54
public void dispose(){
55
if(this.painter != null && !this.painter.getGC().isDisposed()){
56
this.painter.dispose();
58
if(this.buffer != null && !this.buffer.isDisposed()){
59
this.buffer.dispose();
63
public boolean isDisposed(){
64
return (this.buffer == null || this.buffer.isDisposed());