|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Plotter<C>
Plotter is an interface for converting raw data generated by
Starmapper into pixels.
Starmapper calculates influences of Regions on points, where
each point is a center of a pixel. The influences are given as an array of
float values and Plotter's responsibility is to use this
data to plot a relevant pixel with a specific Color. This
Color is calculated from both the influence array and specific
Regions' base Colors. Some Plotters simply choose
the maximum influence, others mix the Regions' Colors in
some way.
The sequence of method calls is as follows:
initNewImage(int, int, List, Config): requests the Plotter to
initialise a new image of its own format, color depth etc.; thw dimensions of
the image and a list of Regions and their Colors are given;
this method returns a "context object", which is an instance of some private
class holding necessary context data understandable by this Plotter -
this object will then be passed to other methods;plot(Object, int, int, int, double[]): called for each relevant
pixel, tells the Plotter what are the influences of Regions
on a pixel at specified coordinates;plotIcon(Object, int, int, Icon),
printString(Object, int, int, String, Font),
printString(Object, int, int, String, Font, Color): usually
Starmapper wants to draw some additional things on the image, like
location of Nodes on the map, their
names and the legend;getImage(Object): finally Starmapper requests the
Plotter to return the image as a BufferedImage.
The "context object" returned by initNewImage(int, int, List, Config) is
completly private to the Plotter. It is used to ensure thread safety
while using a single instance of a Plotter.
| Field Summary | |
|---|---|
static List<Color> |
DEFAULT_COLORS
A List of default Colors, useful when a Region
has no Color defined. |
| Method Summary | |
|---|---|
BufferedImage |
getImage(C context)
Returns the final image as a BufferedImage. |
C |
initNewImage(int width,
int height,
List<Pair<? extends Region,Color>> regions,
Config config)
Initializes a new image with this Plotter's format, the given
dimensions and Regions' Colors. |
void |
plot(C context,
int x,
int y,
int p,
double[] influences)
Tells the Plotter what are the influences of Regions on
the point in the center of pixel at the given coordinates. |
void |
plotIcon(C context,
int x,
int y,
Icon icon)
Plots an Icon at given coordinates; these coordinates locate the
center of the Icon. |
void |
postProcess(C context)
Called after all pixels were plotted and before node
names and icons are plotted. |
void |
printString(C context,
int x,
int y,
String string,
Font font)
Prints a String on the target image, using a Color that's
convenient to the Plotter. |
void |
printString(C context,
int x,
int y,
String string,
Font font,
Color color)
Prints a String on the target image, using the specified
Color. |
| Field Detail |
|---|
static final List<Color> DEFAULT_COLORS
List of default Colors, useful when a Region
has no Color defined. Actually Plotters don't use this
list - Starmapper will assign Colors from this list when
necessary.
| Method Detail |
|---|
C initNewImage(int width,
int height,
List<Pair<? extends Region,Color>> regions,
Config config)
throws ConversionException
Plotter's format, the given
dimensions and Regions' Colors. Returns an object that
holds this image's data for thread-safe use.
Note: width includes Starmapper.PARAM_IMAGE_LEGEND_WIDTH
width - the image's widthheight - the image's heightregions - a List of Regions along with their
Colorsconfig - a Config with optional additional configuration
parameters
ConversionException - if the Config complains
void plot(C context,
int x,
int y,
int p,
double[] influences)
Plotter what are the influences of Regions on
the point in the center of pixel at the given coordinates. The index in
the array of influences determines the Region which this
influence is for - it is the same index as in the List of
Regions and Colors passed to
initNewImage(int, int, List, Config). The implementation of
this method is allowed to modify the influences array - it will be
discarded after the call returns.
context - a context-holding objectx - column index of plotted pixely - row index of plotted pixelp - "pixel number" equal to y * width + xinfluences - array of influences for all regionsvoid postProcess(C context)
plotted and before node
names and icons are plotted. This may be used for example when some more
context than one pixel is needed (see for example
BorderPlotter).
context - a context-holding object
void plotIcon(C context,
int x,
int y,
Icon icon)
Icon at given coordinates; these coordinates locate the
center of the Icon. The Plotter
chooses the Color that's best for the Icon in this
location.
context - a context-holding objectx - x coordinate of the Icon's centery - y coordinate of the Icon's centericon - the Icon to plot
void printString(C context,
int x,
int y,
String string,
Font font)
String on the target image, using a Color that's
convenient to the Plotter. The coordinates given are the
position of top-left corner of the string.
context - a context-holding objectx - left edge of the String to drawy - top edge of the String to drawstring - the String to drawfont - the Font to use
void printString(C context,
int x,
int y,
String string,
Font font,
Color color)
String on the target image, using the specified
Color. The coordinates given are the position of top-left corner
of the string.
context - a context-holding objectx - left edge of the String to drawy - top edge of the String to drawstring - the String to drawfont - the Font to usecolor - the String's ColorBufferedImage getImage(C context)
BufferedImage. The context is free
to be destroyed after the cal to this method.
context - a context-holding object
BufferedImage
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||