1 package de.lathanda.eos.base;
3 import de.lathanda.eos.base.layout.Dimension;
4 import de.lathanda.eos.base.math.Point;
5 import de.lathanda.eos.base.util.GuiToolkit;
6 import de.lathanda.eos.base.layout.Transform;
7 import de.lathanda.eos.game.geom.Shape;
11 import java.util.Collection;
12 import java.util.Iterator;
13 import java.util.LinkedList;
14 import java.util.List;
15 import java.util.StringTokenizer;
93 public abstract void drawLine(
double x1,
double y1,
double x2,
double y2);
107 Iterator<Point> i = points.iterator();
108 Point prev = i.next();
110 while (i.hasNext()) {
126 public final void drawPolygon(Collection<? extends Point> points) {
127 double[] xPoints =
new double[points.size()];
128 double[] yPoints =
new double[points.size()];
130 for (
Point p : points) {
131 xPoints[n] = p.getX();
132 yPoints[n] = p.getY();
142 double[] xPoints =
new double[points.length];
143 double[] yPoints =
new double[points.length];
145 for (
Point p : points) {
146 xPoints[n] = p.getX();
147 yPoints[n] = p.getY();
159 public abstract void drawRect(
double x,
double y,
double width,
double height);
168 public abstract void drawImage(
Image image,
double x,
double y,
double width,
double height);
187 public abstract void drawImage(
Image image,
double x,
double y,
double width,
double height,
boolean mirror,
double angle);
194 public final void drawRect(
double width,
double height) {
195 drawRect(-width/2,-height/2,width,height);
213 public abstract void drawEllipse(
double x,
double y,
double radiusX,
double radiusY);
254 public final void setFont(String fontname,
int size) {
256 font =
new Font(fontname, Font.PLAIN, size);
282 public void drawText(List<String> text,
double left,
double bottom,
double width,
double height) {
283 drawText(text.toArray(
new String[text.size()]), left, bottom, width, height);
295 public void drawText(String[] text,
double left,
double bottom,
double width,
double height) {
297 double textheight = (lineheight +
vspace) * text.length -
vspace;
300 double dx = left + width / 2;
301 double dy = bottom + height / 2;
304 y = textheight/2 - lineheight + descent;
308 y = height/2 -
vspace - lineheight + descent;
312 y = -height/2 + textheight - lineheight +
vspace + descent;
315 for(String textline: text) {
328 x = width/2 - textwidth -
hspace;
343 public final void drawText(String text,
double x,
double y,
double width,
double height) {
344 drawText(split(text), x, y, width, height);
353 public final void drawText(String text,
double x,
double y) {
354 List<String> list = split(text);
381 for(String textline: text) {
402 private List<String> split(String text) {
403 StringTokenizer st =
new StringTokenizer(text,
"\n\r\f",
false);
404 LinkedList<String> list =
new LinkedList<>();
405 while(st.hasMoreTokens()) {
406 list.add(st.nextToken());
464 public abstract void rotate(
double angle);
void setFillStyle(FillStyle ft)
void setColor(MutableColor c)
void setDrawWidth(double width)
void setColor(MutableColor c)
void setLineStyle(LineStyle lt)
void drawEllipse(Point p, double radiusX, double radiusY)
void setLine(LineDescriptor line)
final void setTextSpacing(double hspace, double vspace)
abstract void drawEllipse(double x, double y, double radiusX, double radiusY)
abstract void applyTransform(Transform tf)
void drawText(List< String > text, double left, double bottom, double width, double height)
abstract void drawStringAt(String text, double x, double y)
void setFill(FillDescriptor fill)
final void drawText(String text, double x, double y)
void drawString(String text, Shape shape)
abstract void pushTransform()
abstract double getStringHeight()
void drawText(String[] text, double left, double bottom, double width, double height)
void setLineWidth(double w)
final void drawLine(Point a, Point b)
final void drawRect(double width, double height)
abstract void restoreTransform()
abstract void drawLine(double x1, double y1, double x2, double y2)
Dimension getTextDimension(List< String > text)
final void drawPolygon(Collection<? extends Point > points)
Dimension getTextDimension(String text)
void drawShape(Shape shape)
abstract void drawImage(Image image, double x, double y, double width, double height, Scaling scale)
abstract void drawImage(Image image, double x, double y, double width, double height, boolean mirror, double angle)
final void setFont(String fontname, int size)
void setFillColor(MutableColor c)
abstract void drawImage(Image image, double x, double y, double width, double height)
final void drawPolygon(Point[] points)
abstract double getStringWidth(String text)
final void setTextAlignment(Alignment vertical, Alignment horizontal)
abstract void translate(double dx, double dy)
final void setFont(Font font)
abstract void drawRect(double x, double y, double width, double height)
abstract void drawPolygon(double[] x, double[] y)
final void drawEllipse(double radiusX, double radiusY)
final void drawText(String text, double x, double y, double width, double height)
abstract void rotate(double angle)
abstract double getStringDescent()
final void drawLine(List< Point > points)
void setLineColor(MutableColor c)
void setWidth(double width)
void setHeight(double height)
abstract void draw(Picture picture)