jimgpnt
Class JImagePaintPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by jimgpnt.JImagePaintPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.io.Serializable

public class JImagePaintPanel
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.KeyListener

The core of the jimgpnt package. This is the do-everything class that everything else is based on This panel is designed to go in a JScrollPane and you should set one using setScrollPane(). The panel consists of a background color, an image that has a tranparent chanel (BufferedImage.TYPE_INT_ARGB), some JImagePaintObjects that hover over the image until they are "incorporated", and selected and temporary objects The panel has a notion of the current drawing mode and is sensitive to MouseEvents. It also retains information about various options for createing new JImagePaintObjects.

Copyright (c) 2004 Alistair Dickie. All Rights Reserved. See alistairdickie.com for contact details See licence.txt for licence infomation

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int MODE_COLORPICK
           
static int MODE_ERASE
           
static int MODE_FLOOD
           
static int MODE_LINE
           
static int MODE_OVAL
           
static int MODE_POINT
           
static int MODE_QUADARROW
           
static int MODE_RECT
           
static int MODE_SCRIBBLE
           
static int MODE_SELECT
           
static int MODE_TEXT
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
JImagePaintPanel(java.awt.image.BufferedImage img, java.util.Properties properties)
           
JImagePaintPanel(java.io.File fileToLoad, java.util.Properties properties)
           
JImagePaintPanel(java.util.Properties properties)
          Creates a new image
 
Method Summary
 void appendImageFile(int x, int y)
           
 void copyImageToClipboard()
           
 void copyImageToClipboardwBG()
           
 void copySelected()
           
 void createNewFile()
           
 void deleteSelected()
           
 float getAlpha()
           
 int getArcHeight()
           
 int getArcWidth()
           
 java.awt.Color getBgColor()
           
 int getCurrentMode()
           
 java.util.ArrayList getDisplayObjects()
           
 java.awt.Color getDrawColor()
           
 java.awt.image.BufferedImage getImage()
           
 JImagePaintLocationPanel getLocationPanel()
           
 java.awt.image.BufferedImage getObjectsImage(java.util.ArrayList list)
           
 java.util.ArrayList getPaintObjects()
           
 javax.swing.JScrollPane getScroll()
           
 java.awt.Stroke getStroke()
           
 void imageChanged()
           
 void incorporateSelected()
           
 boolean isAntialiased()
           
 boolean isFilled()
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void openImageFile()
           
 void paintComponent(java.awt.Graphics g)
           
 void pasteImageFromClipboard(java.awt.geom.Point2D clickPoint)
           
 boolean saveImageFile()
           
 void selectAll()
           
 void setAlpha(float alpha)
           
 void setAntialiased(boolean antialiased)
           
 void setArcHeight(int arcHeight)
           
 void setArcWidth(int arcWidth)
           
 void setBgColor(java.awt.Color bgColor)
           
 void setCurrentMode(int currentmode)
           
 void setDisplayObjects(java.util.ArrayList displayObjects)
           
 void setDrawColor(java.awt.Color drawColor)
           
 void setFilled(boolean filled)
           
 void setFont(java.awt.Font font)
           
 void setLocationPanel(JImagePaintLocationPanel panel)
           
 void setScroll(javax.swing.JScrollPane scroll)
           
 void setStroke(java.awt.Stroke stroke)
           
 void textFinished(JImageTextObject textObject)
           
 void zoomed(java.awt.Point center)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_LINE

public static final int MODE_LINE
See Also:
Constant Field Values

MODE_SCRIBBLE

public static final int MODE_SCRIBBLE
See Also:
Constant Field Values

MODE_RECT

public static final int MODE_RECT
See Also:
Constant Field Values

MODE_OVAL

public static final int MODE_OVAL
See Also:
Constant Field Values

MODE_TEXT

public static final int MODE_TEXT
See Also:
Constant Field Values

MODE_SELECT

public static final int MODE_SELECT
See Also:
Constant Field Values

MODE_ERASE

public static final int MODE_ERASE
See Also:
Constant Field Values

MODE_FLOOD

public static final int MODE_FLOOD
See Also:
Constant Field Values

MODE_POINT

public static final int MODE_POINT
See Also:
Constant Field Values

MODE_QUADARROW

public static final int MODE_QUADARROW
See Also:
Constant Field Values

MODE_COLORPICK

public static final int MODE_COLORPICK
See Also:
Constant Field Values
Constructor Detail

JImagePaintPanel

public JImagePaintPanel(java.io.File fileToLoad,
                        java.util.Properties properties)
Parameters:
fileToLoad - An File objected representing an image that ImageIO can read. The image is set to the
properties - A properties object in which to create and load properties

JImagePaintPanel

public JImagePaintPanel(java.awt.image.BufferedImage img,
                        java.util.Properties properties)
Parameters:
img - A bufferedImage that will
properties - A properties object in which to create and load properties

JImagePaintPanel

public JImagePaintPanel(java.util.Properties properties)
Creates a new image

Parameters:
properties - A properties object in which to create and load properties
Method Detail

getLocationPanel

public JImagePaintLocationPanel getLocationPanel()

setLocationPanel

public void setLocationPanel(JImagePaintLocationPanel panel)

getBgColor

public java.awt.Color getBgColor()

setBgColor

public void setBgColor(java.awt.Color bgColor)

createNewFile

public void createNewFile()

openImageFile

public void openImageFile()

getImage

public java.awt.image.BufferedImage getImage()

appendImageFile

public void appendImageFile(int x,
                            int y)

saveImageFile

public boolean saveImageFile()

getAlpha

public float getAlpha()

setAlpha

public void setAlpha(float alpha)

getStroke

public java.awt.Stroke getStroke()

setStroke

public void setStroke(java.awt.Stroke stroke)

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class javax.swing.JComponent

getCurrentMode

public int getCurrentMode()

setCurrentMode

public void setCurrentMode(int currentmode)

getScroll

public javax.swing.JScrollPane getScroll()

setScroll

public void setScroll(javax.swing.JScrollPane scroll)

isAntialiased

public boolean isAntialiased()

setAntialiased

public void setAntialiased(boolean antialiased)

getDrawColor

public java.awt.Color getDrawColor()

getArcWidth

public int getArcWidth()

setArcWidth

public void setArcWidth(int arcWidth)

getArcHeight

public int getArcHeight()

setArcHeight

public void setArcHeight(int arcHeight)

setDrawColor

public void setDrawColor(java.awt.Color drawColor)

imageChanged

public void imageChanged()

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

isFilled

public boolean isFilled()

setFilled

public void setFilled(boolean filled)

getPaintObjects

public java.util.ArrayList getPaintObjects()

getObjectsImage

public java.awt.image.BufferedImage getObjectsImage(java.util.ArrayList list)

getDisplayObjects

public java.util.ArrayList getDisplayObjects()

setDisplayObjects

public void setDisplayObjects(java.util.ArrayList displayObjects)

copyImageToClipboard

public void copyImageToClipboard()

copyImageToClipboardwBG

public void copyImageToClipboardwBG()

pasteImageFromClipboard

public void pasteImageFromClipboard(java.awt.geom.Point2D clickPoint)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

zoomed

public void zoomed(java.awt.Point center)

deleteSelected

public void deleteSelected()

copySelected

public void copySelected()

selectAll

public void selectAll()

incorporateSelected

public void incorporateSelected()

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

textFinished

public void textFinished(JImageTextObject textObject)


Copyright © 2004 Alistair Dickie. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

1. The origin of this Software must not be misrepresented; you must not claim that you wrote the original software. If you use the Software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original Software.

3. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Alistair Dickie - See alistairdickie.com for contact details.