|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--uk.org.redfelineninja.awt.PixMap
A component similar to Canvas but with per pixel access built in. This class originated through dissatisfaction with java.awt.Graphics. I need to test the colour of a pixel. java.awt.Graphics does not seem to provide this.
Field Summary |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
PixMap(java.awt.Image img)
Create a new PixMap from an Image using a direct RGB colour mapping. |
|
PixMap(java.awt.Image img,
java.awt.image.ColorModel cm)
Create a PixMap from an Image using the supplied ColorModel. |
Method Summary | |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line interior to the supplied points. |
java.awt.Rectangle |
floodFill(int x,
int y)
Uses a simple recursive algorithm to perform a flood fill. |
java.awt.Rectangle |
floodFillOld(int x,
int y)
|
boolean |
getAutoRepaint()
Find whether or not the PixMap will automatically repaint itself. |
int |
getColor()
Get the current draw colour. |
java.awt.image.ColorModel |
getColorModel()
Returns the ColorModel used when creating the image from the PixMap |
java.awt.Image |
getImage()
Supplies the Image version of the PixMap. |
java.awt.Dimension |
getMaximumSize()
Get the maximum size of this component. |
java.awt.Dimension |
getMinimumSize()
Get the minimum size of this component. |
int |
getPixel(int x,
int y)
Get the colour of the pixel at (x, y). |
int |
getPixel(java.awt.Point d)
Get the colour of the pixel at the supplied point. |
int[] |
getPixels()
Supplies the pixels used in this PixMap. |
java.awt.Dimension |
getPreferredSize()
Get the preferred size of this component. |
boolean |
loadImage()
Ensures the image is ready to be output. |
void |
newPixels()
Tells the PixMap that the whole of is pixels need to be updated. |
void |
newPixels(int x,
int y,
int w,
int h)
Tells the PixMap that the pixels within the supplied box need to be updated. |
void |
paint(java.awt.Graphics g)
Draw the Image as supplied by getImage to screen. |
void |
setAutoRepaint(boolean ar)
Set whether or not the PixMap will automatically repaint itself. |
void |
setColor(java.awt.Color c)
Sets the draw colour. |
void |
setColor(int c)
Sets the draw colour. |
void |
setColorModel(java.awt.image.ColorModel cm)
Sets the ColorModel used when creating the image from the PixMap |
void |
setPixel(int x,
int y,
int color)
Set the colour of the pixel at (x, y). |
void |
setPixel(java.awt.Point d,
int color)
Set the colour of the pixel at the supplied point. |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PixMap(java.awt.Image img)
img
- Image from which to generate the PixMappublic PixMap(java.awt.Image img, java.awt.image.ColorModel cm)
img
- Image from which to generate the PixMapcm
- ColorModel to apply to the imageColorModel
Method Detail |
public java.awt.Image getImage()
public final int[] getPixels()
public final int getPixel(int x, int y)
public final int getPixel(java.awt.Point d)
public final void setPixel(int x, int y, int color)
color
- Integer representing a colour. Bits 24-31 represent alpha, 16-23, red, 8-15 green and 0-7 blue.public final void setPixel(java.awt.Point d, int color)
color
- Integer representing a colour. Bits 24-31 represent alpha, 16-23, red, 8-15 green and 0-7 blue.public java.awt.image.ColorModel getColorModel()
getColorModel
in class java.awt.Component
public void setColorModel(java.awt.image.ColorModel cm)
public int getColor()
public void setColor(int c)
c
- Integer representing a colour. Bits 24-31 represent alpha, 16-23, red, 8-15 green and 0-7 blue.public void setColor(java.awt.Color c)
public void drawLine(int x1, int y1, int x2, int y2)
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Component
getPixels()
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class java.awt.Component
getPixels()
public java.awt.Dimension getMaximumSize()
getMaximumSize
in class java.awt.Component
getPixels()
public boolean getAutoRepaint()
public void setAutoRepaint(boolean ar)
ar
- true if the PixMap should automatically repaint.public java.awt.Rectangle floodFill(int x, int y)
WARNING
The algorithm to perform flood filling is deeply recursive. It works
fine on most virtual machines. It only works for very small areas
on PersonalJava VMs, it throws a StackOverflowException if
it does not work. It will be updated when a better way comes to light.
public java.awt.Rectangle floodFillOld(int x, int y)
public void newPixels()
public void newPixels(int x, int y, int w, int h)
x
- the x coordinate of the upper left corner of the new Pixelsy
- the y coordinate of the upper left corner of the new Pixelsw
- the width of the rectangleh
- the height of the rectanglepublic boolean loadImage()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Component
getImage()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |