package com.ddChat.graphic;
import java.awt.Graphics;
public class YScale extends Scale
{
GData min;
GData max;
private final int MAJOR_TICK_LEN = 10;
public YScale(Graphics g)
{
super(g);
min = new GData(1, 2);
max = new GData(300, 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 = 0;
int x2 = 0;
int y1 = (int) ti.getAlignMin().getValue();
int y2 = (int) ti.getAlignMax().getValue();;
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 = 0;
x2 = x1 + MAJOR_TICK_LEN;
y1 = (int) (ti.getAlignMin().getValue() + tickProp.getTickInterval() * i);
y2 = (int) (ti.getAlignMin().getValue() + tickProp.getTickInterval() * i);
g.drawLine(x1, y1, x2, y2);
}
}
public void draw()
{
System.out.println("xscale draw called");
drawSkel();
drawMajorTick();
}
}
阅读(2060) | 评论(0) | 转发(0) |