org.minueto.image
Interface MinuetoDrawingSurface

All Known Subinterfaces:
MinuetoWindow
All Known Implementing Classes:
MinuetoCircle, MinuetoFrame, MinuetoFullscreen, MinuetoImage, MinuetoImageFile, MinuetoPanel, MinuetoRectangle, MinuetoText

public interface MinuetoDrawingSurface

This interface denotes an object which can be drawn to with images or lines As well as having a width and height, pxels can be accessed or set It is also possible to save the image to a file. This interface was created to solidy the similarities between a MinuetoWindow and a MinuetoImage

Since:
1.1
See Also:
MinuetoImage, MinuetoBaseWindow

Method Summary
 void clear()
          Clears the contents of the Drawing Surface.
 void clear(MinuetoColor color)
          Erases the contents from the Drawing Surface.
 void draw(MinuetoImage image, int x, int y)
          Draw another MinuetoImage on this MinuetoDrawingSurface (thus compositing them).
 void drawLine(MinuetoColor color, int xStart, int yStart, int xStop, int yStop)
          Draw a line of the specified color from the start point to the end point.
 int getHeight()
          Return the height of the image.
 int getWidth()
          Return the width of the image.
 void save(java.lang.String filename)
          Saves the content of the MinuetoDrawingSurface to a PNG file.
 void setPixel(int x, int y, MinuetoColor color)
          Change the color of pxel at location X,y.
 

Method Detail

clear

void clear()
Clears the contents of the Drawing Surface. The color that remains depends on the JVM.

Since:
1.2

clear

void clear(MinuetoColor color)
Erases the contents from the Drawing Surface. The color of the cleared surface is specified as a parameter.

Parameters:
color - MinuetoColor of the cleared buffer.
Since:
1.2

setPixel

void setPixel(int x,
              int y,
              MinuetoColor color)
Change the color of pxel at location X,y.

This uses the drawLine function to be faster than a direct raw data setPxel, though it should be used with caution as it is still slower than drawing a completed image to the drawing surface.

Parameters:
x - int denoting which pxel on the X axis should be colored.
y - int denoting which pxel on the y axis should be colored.
color - MinuetoColor denoting the new color for pxel x,y.
Since:
1.1

draw

void draw(MinuetoImage image,
          int x,
          int y)
Draw another MinuetoImage on this MinuetoDrawingSurface (thus compositing them).

Parameters:
image - MinuetoImage that we will draw on our image.
x - int denoting where we should start drawing on the x axis.
y - int denothing where we should start drawing on the y axis.

drawLine

void drawLine(MinuetoColor color,
              int xStart,
              int yStart,
              int xStop,
              int yStop)
Draw a line of the specified color from the start point to the end point.

Parameters:
color - MinuetoColor denoting the color of the line.
xStart - int denoting the X value of the start point.
yStart - int denoting the Y value of the start point.
xStop - int denoting the X value of the end point.
yStop - int denoting the Y value of the end point.
Throws:
MinuetoOutOfBoundException - if the target coordinates are not valid.

getWidth

int getWidth()
Return the width of the image.

Returns:
int denoting the width of the image.

getHeight

int getHeight()
Return the height of the image.

Returns:
int denoting the height of the image.

save

void save(java.lang.String filename)
          throws MinuetoFileException
Saves the content of the MinuetoDrawingSurface to a PNG file. Since this method requires File I/O, it is somewhat slow. However, this method can be used as a debugging tool.

Parameters:
filename - String indicating the name of the PNG file.
Throws:
MinuetoFileException - if it cannot write the file.
MinuetoFileException