Package de.erichseifert.gral.graphics


package de.erichseifert.gral.graphics

The drawing primitives that every visible part of a plot is built from.

Drawable is a lightweight component: it has bounds, a preferred size, and a draw method. It deliberately does not extend java.awt.Component, which is what allows the same object to be painted into a Swing panel, an image, a PDF, or a printer page. AbstractDrawable implements the bounds handling, so subclasses only have to supply draw and usually getPreferredSize.

Drawable cross = new AbstractDrawable() {
    public void draw(DrawingContext context) {
        Graphics2D g = context.getGraphics();
        g.draw(new Line2D.Double(getX(), getY(),
            getX() + getWidth(), getY() + getHeight()));
    }
};
cross.setBounds(0.0, 0.0, 100.0, 50.0);
cross.draw(new DrawingContext(graphics2D));

DrawingContext carries the Graphics2D to paint on together with two hints: a DrawingContext.Target that says whether the output is a pixel raster or a vector document, and a DrawingContext.Quality level. Renderers check the target to decide, for example, whether a gradient can be emitted as vector data or has to be rasterized first.

DrawableContainer holds child drawables and positions them with a Layout; this is the base class of AbstractPlot. Label draws a rotatable, alignable piece of text and is used for plot titles, axis labels and legend entries. Insets2D, Dimension2D, Location and Orientation are the small geometry types that the AWT lacks in double precision or at all.

Siehe auch: