001    package org.bukkit.map;
002    
003    import java.awt.Image;
004    
005    /**
006     * Represents a canvas for drawing to a map. Each canvas is associated with a
007     * specific {@link MapRenderer} and represents that renderer's layer on the
008     * map.
009     */
010    public interface MapCanvas {
011    
012        /**
013         * Get the map this canvas is attached to.
014         *
015         * @return The MapView this canvas is attached to.
016         */
017        public MapView getMapView();
018    
019        /**
020         * Get the cursor collection associated with this canvas.
021         *
022         * @return The MapCursorCollection associated with this canvas.
023         */
024        public MapCursorCollection getCursors();
025    
026        /**
027         * Set the cursor collection associated with this canvas. This does not
028         * usually need to be called since a MapCursorCollection is already
029         * provided.
030         *
031         * @param cursors The MapCursorCollection to associate with this canvas.
032         */
033        public void setCursors(MapCursorCollection cursors);
034    
035        /**
036         * Draw a pixel to the canvas.
037         *
038         * @param x The x coordinate, from 0 to 127.
039         * @param y The y coordinate, from 0 to 127.
040         * @param color The color. See {@link MapPalette}.
041         */
042        public void setPixel(int x, int y, byte color);
043    
044        /**
045         * Get a pixel from the canvas.
046         *
047         * @param x The x coordinate, from 0 to 127.
048         * @param y The y coordinate, from 0 to 127.
049         * @return The color. See {@link MapPalette}.
050         */
051        public byte getPixel(int x, int y);
052    
053        /**
054         * Get a pixel from the layers below this canvas.
055         *
056         * @param x The x coordinate, from 0 to 127.
057         * @param y The y coordinate, from 0 to 127.
058         * @return The color. See {@link MapPalette}.
059         */
060        public byte getBasePixel(int x, int y);
061    
062        /**
063         * Draw an image to the map. The image will be clipped if necessary.
064         *
065         * @param x The x coordinate of the image.
066         * @param y The y coordinate of the image.
067         * @param image The Image to draw.
068         */
069        public void drawImage(int x, int y, Image image);
070    
071        /**
072         * Render text to the map using fancy formatting. Newline (\n) characters
073         * will move down one line and return to the original column, and the text
074         * color can be changed using sequences such as "§12;", replacing 12 with
075         * the palette index of the color (see {@link MapPalette}).
076         *
077         * @param x The column to start rendering on.
078         * @param y The row to start rendering on.
079         * @param font The font to use.
080         * @param text The formatted text to render.
081         */
082        public void drawText(int x, int y, MapFont font, String text);
083    
084    }