view src/samer/tools/Renderer.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
package samer.tools;

import samer.core.util.*;
import java.awt.*;

public interface Renderer {
	public void draw( Graphics g, int x1, int x2, int j1, int j2, int j0);

	class Line implements Renderer {
		public void draw( Graphics g, int x1, int x2, int j1, int j2, int j0) {
			g.drawLine(x1,j1,x2,j2);
		}
	}

	class Fill implements Renderer {
		public void draw( Graphics g, int x1, int x2, int j1, int j2, int j0) {
			if (j2>j0) g.fillRect(x1,j0,x2-x1,j2-j0);
			else g.fillRect(x1,j2,x2-x1,j0-j2);
		}
	}

	class Fill3D implements Renderer {
		public void draw( Graphics g, int x1, int x2, int j1, int j2, int j0) {
			// need to make sure rectangle is the right way up
			if (j2>j0) g.fill3DRect(x1,j0,x2-x1,j2-j0,true);
			else g.fill3DRect(x1,j2,x2-x1,j0-j2,true);
		}
	}

	class Steps implements Renderer {
		public void draw( Graphics g, int x1, int x2, int j1, int j2, int j0) {
			g.drawLine(x1,j1,x1,j2);
			g.drawLine(x1,j2,x2,j2);
		}
	}
	public final static Renderer LINE=new Line();
	public final static Renderer FILL=new Fill();
	public final static Renderer FILL3D=new Fill3D();
	public final static Renderer STEPS=new Steps();
}