package com.ddChat.graphic;
import java.awt.Graphics;
public class XScale extends Scale
{
GData min ;
GData max ;
private final int MAJOR_TICK_LEN = 10;
public XScale(Graphics g)
{
super(g);
min = new GData(1, 2);
max = new GData(290, 2);
}
@Override
void setG(Graphics g)
{
this.g = g;
}
@Override
void drawSkel()
{
if(g == null){
System.out.println("xscale drawSkel g == null,return");
return;
}
TickInfo ti = new TickInfo(min, max);
int x1 = (int) ti.getAlignMin().getValue();
int x2 = (int) ti.getAlignMax().getValue();
int y1 = Config.GRAPHIC_SCREEN_HEIGHT;
int y2 = Config.GRAPHIC_SCREEN_HEIGHT;
g.drawLine(x1, y1, x2, y2);
}
@Override
void drawMajorTick()
{
int x1,x2 ,y1 ,y2 ;
if(g == null){
System.out.println("xscale drawMajorTick g == null,return");
return;
}
TickInfo ti = new TickInfo(min, max);
tickProp = ti.getAlignedTickProp();
System.out.println(tickProp);
for(int i = 0 ; i <= tickProp.getTickCount(); i++)
{
x1 = (int) (ti.getAlignMin().getValue() + tickProp.getTickInterval() * i);
x2 = x1 ;
y1 = Config.GRAPHIC_SCREEN_HEIGHT;
y2 = Config.GRAPHIC_SCREEN_HEIGHT - MAJOR_TICK_LEN;
g.drawLine(x1, y1, x2, y2);
}
}
public void draw()
{
System.out.println("xscale draw called");
drawSkel();
drawMajorTick();
}
}
阅读(1910) | 评论(0) | 转发(0) |