|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--ach.ImagePanel
ImagePanel.java
Copyright (C) 1997-2006 H. Hackbarth, All Rights Reserved
Panel used as container to display images. Contains scrollbars and several
display control buttons.
For examples how to use this class please refer to TiffyApplet.java and
SwingTiffy.java. Parameter options can be found in method parseOptions().
ImagePanel embeds either the heavyweight class ImgCanvas or the
lightweight class ImgComponent to handle the image display. The code
contains remarks (search for "lightweight") how to do the required
replacements.
THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY
DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
boolean |
frameUpdated
flag needed due to bug in MS VM version 2334; see example SwingTiffy.java |
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 | |
ImagePanel(java.awt.Container parent,
byte[] imgFileBA,
java.lang.String options,
boolean showButtonPanel)
constructor for ImagePanel (image passed as ByteArray) |
|
ImagePanel(java.awt.Container parent,
java.awt.Image img,
java.lang.String options,
boolean showButtonPanel)
constructor for ImagePanel (image passed as java.awt.Image) |
|
ImagePanel(java.awt.Container parent,
java.lang.String name,
java.lang.String options,
boolean showButtonPanel)
constructor for ImagePanel (image names passed as String) |
|
ImagePanel(java.awt.Container parent,
java.net.URL context,
java.lang.String options,
boolean showButtonPanel)
constructor for ImagePanel (image names passed as URL) |
Method Summary | |
boolean |
action(java.awt.Event evt,
java.lang.Object arg)
The action handler should not be necessary as all events should be handled already by handleEvent() |
void |
addAnnotationsControl(java.awt.Component c)
a component specified here will be enabled/disabled depending if annotations exist beside the image |
void |
addNextPageControl(java.awt.Component c)
a component specified here will be enabled/disabled depending if there is a "next page" in the list of multiple images |
void |
addPrevPageControl(java.awt.Component c)
a component specified here will be enabled/disabled depending if there is a "previous page" in the list of multiple images |
void |
addPrintControl(java.awt.Component c)
a component specified here will be enabled/disabled depending printing of the image is enabled |
void |
addPrintViewControl(java.awt.Component c)
a component specified here will be enabled/disabled depending printing of the viewable part of the image is enabled |
void |
addSaveControl(java.awt.Component c)
a component specified here will be enabled/disabled depending saving of the image is enabled |
void |
addScaleSmoothControl(java.awt.Component c)
a component specified here will be enabled/disabled depending on the state of btnScaleSmooth |
void |
addThumbnailsControl(java.awt.Component c)
a component specified here will be enabled/disabled depending if a thumbnail preview is displayed |
void |
batchPrint(java.lang.Object printJob,
int preferredResolution,
java.lang.String printPageSelection)
Print all slides of a slide sequence and/or all pages of a multipage TIFF either to a PrintJob (JDK 1.1) or PrinterJob (Java 2) (one of them must be not null). |
void |
cleanUp()
Clean up code to free all ressources that may be used by this component |
void |
fitHoriz()
scale image to fit into the window horizontally |
void |
fitInWindow()
scale image to fit into the window completely |
boolean |
flip()
flip image vertically |
java.lang.String |
getAnnotations(boolean resetModifiedState)
Get currently loaded / edited annotations. |
int |
getPageNum()
ToolbarController: get text of PageNum TextField converted to int |
double |
getZoomFactor(double defaultZoom)
ToolbarController: get zoom factor from zoom TextField |
boolean |
handleEvent(java.awt.Event evt)
The handleEvent() method receives all events generated within the frame window. |
void |
imageProducerUpdate(java.awt.image.ImageProducer imgSrc,
java.lang.String errorMsg,
ImageInfo imgInfo)
The createImageProducer() method of class ImageInfo works asynchronously and will call the imageProducerUpdate method of an ImgProdObserver (implemented by this viewer class!). |
boolean |
imageUpdate(java.awt.Image img,
int flags,
int x,
int y,
int w,
int h)
Callback function to monitor image drawing process will be called several times during drawImage (why not called in JDK 1.1?) |
boolean |
invert()
invert image |
void |
loadImage(ImageInfo imgInfo)
Comfortable method to load image (using format autodection); runs createImageProducer() and asynchronously calls back imageProducerUpdate() which finally calls showPanel() to display the image. |
boolean |
mirror()
mirror image horizontally |
boolean |
navigation()
show navigation frame ("grabber hand") |
void |
paint(java.awt.Graphics g)
Paint Handler of this component |
boolean |
printCurrentView(boolean asynchronousFlag)
Open print dialog and start printing the current viisible area of the image |
boolean |
printImage(boolean asynchronousFlag)
Open print dialog and start printing the current image |
boolean |
rotate090()
rotate image by 90 degree |
boolean |
rotate180()
rotate image by 180 degree |
boolean |
rotate270()
rotate image by 270 degree |
void |
saveAnnotations()
Default implementation of the AnnotationSaver interface to save current annotations. |
void |
scrollAbs(int x,
int y)
Implementation of Scrollable interface |
void |
setAnnotations(java.lang.String annotations)
Set (or replace current) annotations and refresh display. |
void |
setAnnotationSaver(AnnotationSaver as)
Replace default AnnotationSaver implementation with your own implementation. |
boolean |
setNextPage()
for multi-document images step forward to next page for a slide sequence increment slide index |
void |
setNumPagesText(int numPages)
ToolbarController: set text of numPages Label to number of pages |
boolean |
setPageNum(int pageNum)
for multi-document images step to indicated page for a slide sequence set slide index to indicated slide |
void |
setPageNumText(int pageNum)
ToolbarController: set text of PageNum TextField to page number |
boolean |
setPreviousPage()
for multi-document images step back to previous page for a slide sequence decrement slide index |
void |
setToolbarController(ToolbarController tbc)
Set implementation to be used according to ToolbarController interface |
void |
setZoomText(double zoomFactor)
ToolbarController: set text of zoom TextField to zoomFactor (update only if current text is different to avoid unnecessary repaints) |
void |
showKeyHelp()
show help file with key map |
void |
toggleAnnotations()
toggle display of annotations |
void |
toggleSmoothScaling()
toggle smooth scaling (antialiasing) |
void |
toggleThumbnails()
Toggle display of thumbnail preview |
void |
update(java.awt.Graphics g)
Override component's update method to suppress clearing of the screen |
void |
updatePageNum()
update pageNum text field and numpages label for a slide sequence set pageNum to slide index for a multi-document image set pageNum to page index |
void |
zoom(double zoom)
set free defined zoom factor and calulate new image offset for centered image |
void |
zoom1To1()
set 1:1 view (zoom factor 1) and calulate new image offset for centered image |
void |
zoomIn()
increase zoom factor and calulate new image offset for centered image |
void |
zoomOut()
decrease zoom factor and calulate new image offset for centered image |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree |
Methods inherited from class java.awt.Component |
add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public boolean frameUpdated
Constructor Detail |
public ImagePanel(java.awt.Container parent, java.net.URL context, java.lang.String options, boolean showButtonPanel)
parent
- is the container where this component is to be embeddedURL
- points to the location of the image to be displayedoptions
- String with display control options (please refer to TiffyAppletDoc.html)showButtonPanel
- flag controls if the (AWT-based) button panel should be displaydpublic ImagePanel(java.awt.Container parent, java.lang.String name, java.lang.String options, boolean showButtonPanel)
parent
- is the container where this component is to be embeddedname
- holds the pathname(s) of the image(s) to be displayed (separated by semicolon)options
- String with display control options (please refer to TiffyAppletDoc.html)showButtonPanel
- flag controls if the (AWT-based) button panel should be displaydpublic ImagePanel(java.awt.Container parent, byte[] imgFileBA, java.lang.String options, boolean showButtonPanel)
parent
- is the container where this component is to be embeddedimgFileBA
- holds the ByteArray containing the image file (currently only TIFF, JPG, GIF)options
- String with display control options (please refer to TiffyAppletDoc.html)showButtonPanel
- flag controls if the (AWT-based) button panel should be displaydpublic ImagePanel(java.awt.Container parent, java.awt.Image img, java.lang.String options, boolean showButtonPanel)
parent
- is the container where this component is to be embeddedimg
- holds the image to be displayedoptions
- String with display control options (please refer to TiffyAppletDoc.html)showButtonPanel
- flag controls if the (AWT-based) button panel should be displaydMethod Detail |
public void addSaveControl(java.awt.Component c)
c
- Component to be controlledpublic void addPrintControl(java.awt.Component c)
c
- Component to be controlledpublic void addPrintViewControl(java.awt.Component c)
c
- Component to be controlledpublic void addPrevPageControl(java.awt.Component c)
c
- Component to be controlledpublic void addNextPageControl(java.awt.Component c)
c
- Component to be controlledpublic void addThumbnailsControl(java.awt.Component c)
c
- Component to be controlledpublic void addAnnotationsControl(java.awt.Component c)
c
- Component to be controlledpublic void addScaleSmoothControl(java.awt.Component c)
c
- Component to be controlledpublic void setToolbarController(ToolbarController tbc)
tbc
- implementation of ToolbarController interfacepublic void cleanUp()
public void showKeyHelp()
public boolean navigation()
public void toggleThumbnails()
public java.lang.String getAnnotations(boolean resetModifiedState)
resetModifiedState
- flag. If true, all modified flags will be reset to unmodified.public void setAnnotations(java.lang.String annotations)
annotations
- String containing an XML representation of the annotations.public void setAnnotationSaver(AnnotationSaver as)
AnnotationSaver
- an instance of a class implementing ach.vectorGraphics.AnnotationSaver interface.public void saveAnnotations()
saveAnnotations
in interface AnnotationSaver
public void scrollAbs(int x, int y)
scrollAbs
in interface Scrollable
x
- absolute x-position of upper left edge of viewable rectangley
- absolute y-position of upper left edge of viewable rectanglepublic void zoomIn()
public void zoomOut()
public void zoom(double zoom)
public void zoom1To1()
public void fitHoriz()
public void fitInWindow()
public void toggleSmoothScaling()
public void toggleAnnotations()
public boolean setPageNum(int pageNum)
pageNum
- index of targeted page; counting starts with 1public boolean setPreviousPage()
public boolean setNextPage()
public void setPageNumText(int pageNum)
setPageNumText
in interface ToolbarController
public int getPageNum()
getPageNum
in interface ToolbarController
public void setNumPagesText(int numPages)
setNumPagesText
in interface ToolbarController
public void setZoomText(double zoomFactor)
setZoomText
in interface ToolbarController
public double getZoomFactor(double defaultZoom)
getZoomFactor
in interface ToolbarController
public void updatePageNum()
public boolean rotate090()
public boolean rotate180()
public boolean rotate270()
public boolean mirror()
public boolean flip()
public boolean invert()
public boolean printImage(boolean asynchronousFlag)
asynchronousFlag
- controls whether printing should be carried
out as asynchronous thread or synchronously
Another more detailed example to use PrintDialog and PrintImage see method printOverlayedImage.public boolean printCurrentView(boolean asynchronousFlag)
asynchronousFlag
- controls whether printing should be carried
out as asynchronous thread or synchronously
Another more detailed example to use PrintDialog and PrintImage see method printOverlayedImage.public void batchPrint(java.lang.Object printJob, int preferredResolution, java.lang.String printPageSelection)
batchPrint
in interface BatchPrinter
printJob
- instance of PrintJob (e.g. instantiated by PrintDialog) or PrinterJobpreferredResolution
- specifies the preferred print resolution (only used for MS IE)pageRange
- page numbers seperated by semicolons and low - high ranges like 1;2;8-10public boolean handleEvent(java.awt.Event evt)
handleEvent
in class java.awt.Component
evt
- Event to be handledpublic boolean action(java.awt.Event evt, java.lang.Object arg)
action
in class java.awt.Component
evt
- Event to be handledarg
- the argument objectpublic void imageProducerUpdate(java.awt.image.ImageProducer imgSrc, java.lang.String errorMsg, ImageInfo imgInfo)
imageProducerUpdate
in interface ImgProdObserver
imgSrc
- ImageProducer that was created asynchronouslyerrorMsg
- String that contains an error message if an error occured during ImageProducer creationimgInfo
- the ImageInfo object containing the imgName string (used if error is displayed)public void loadImage(ImageInfo imgInfo)
imgInfo
- an instance of class ImageInfo used to specify URL or filename
of the image and set the desired pagenumber (if a multipage image is loaded).public boolean imageUpdate(java.awt.Image img, int flags, int x, int y, int w, int h)
imageUpdate
in class java.awt.Component
Component.imageUpdate(java.awt.Image, int, int, int, int, int)
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
g
- Graphics context to be paintedpublic void update(java.awt.Graphics g)
update
in class java.awt.Container
g
- Graphics context to be painted
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |