diff options
author | Graydon Hoare <graydon@gcc.gnu.org> | 2004-11-30 23:59:12 +0000 |
---|---|---|
committer | Graydon Hoare <graydon@gcc.gnu.org> | 2004-11-30 23:59:12 +0000 |
commit | ea28b8f60fb4113053238a22a4d2c508f39710bb (patch) | |
tree | 35ad0bbb429ac9e5e658fea57b904ce331b0a4dd /libjava/java/awt/image | |
parent | c21accc5d9378aa5b20c868364d8025faa5b1ea5 (diff) | |
download | gcc-ea28b8f60fb4113053238a22a4d2c508f39710bb.zip gcc-ea28b8f60fb4113053238a22a4d2c508f39710bb.tar.gz gcc-ea28b8f60fb4113053238a22a4d2c508f39710bb.tar.bz2 |
revert: [multiple changes]
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphics.java (drawImage variants):
Update image observer.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (createImage):
Start image production.
* gnu/java/awt/peer/gtk/GtkFramePeer.java (setMenuBar): Protect
against negative menu bar widths.
(setBounds): Likewise.
(postConfigureEvent): Likewise.
* gnu/java/awt/peer/gtk/GtkImage.java (imageComplete): Don't
remove consumer unless only a single frame has completed.
* gnu/java/awt/peer/gtk/GtkImagePainter.java (GtkImagePainter):
Add observer parameter.
(setPixels): Update image observer.
(imageComplete): Likewise.
* java/applet/Applet.java (width): New field.
(height): Likewise.
(setStub): Set size if width or height field has been set.
(resize): If stub is null save width and height values.
* java/awt/Component.java (reshape): Protect against null
parent.
* java/awt/image/MemoryImageSource.java
(MemoryImageSource(int,int,ColorModel,byte[],int,int)):
Document.
(MemoryImageSource(int,int,ColorModel,int[],int,int)):
Likewise.
(MemoryImageSource(int,int,ColorModel,byte[],int,int,Hashtable)):
Reference pixel array directly, rather than creating a local
copy.
(MemoryImageSource(int,int,ColorModel,int[],int,int,Hashtable)):
Likewise.
(newPixels(int,int,int,int)): Fix for loop and array copy
bounds.
(newPixels(int,int,int,int,boolean)): Likewise.
(startProduction): If animated call imageComplete with
SINGLEFRAME.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Uncomment
gdk_flush lines.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
(drawPixels): Return if g is null or g->drawable is not a gdk
drawable.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/DefaultSingleSelectionModel.java,
javax/swing/JPasswordField.java,
javax/swing/tree/AbstractLayoutCache.java:
Reformatted and javadocs cleaned up.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/Component.java:
Fixed argument names to match javadocs.
(setFont): Rewritten set property first and then fire event.
(setLocale): Likewise.
* javax/swing/text/JTextComponent.java
(setEditable): Likewise.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Button.java
(AccessibleAWTButton.getAccessibleActionDescription): Explain the
source of 'click'.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Checkbox.java: Remove stub comments.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Button.java
(AccessibleAWTButton.getAccessibleActionDescription): Return
'click'.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/CardLayout.java:
Made some constants static.
(serialVersionUID): Made private.
(addLayoutComponent): Simplified code.
* java/awt/event/InputEvent.java
(getModifiersEx): Added missing @param tag.
* java/awt/image/RGBImageFilter.java
(filterRGBPixels): Reformatted, removed wrong @param tag.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/text/FieldView.java,
javax/swing/text/JTextComponent.java:
Removed debug code.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/BorderFactory.java
(BorderFactory): Added private constructor.
* javax/swing/SwingUtilities.java
(SwingUtilities): Likewise.
(computeStringWidth): New method.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/color/ICC_Profile.java
(icSigNamedColorTag): Removed.
* java/awt/datatransfer/DataFlavor.java
(isMimeTypeEqual): Made final.
* java/awt/image/AffineTransformOp.java:
Reworked javadocs.
(TYPE_BICUBIC): Added @since tag.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Checkbox.java (AccessibleAWTCheckBox): Remove todo
comments.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Checkbox.java (itemStateChanged): Implement function.
(getAccessibleContext): Add AccessibleAWTCheckBox to item listeners.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/Polygon.java (contains): Reimplemented.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/print/PrinterJob.java: Reformatted.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/image/AffineTransformOp.java,
java/awt/image/ColorConvertOp.java,
java/awt/image/LookupOp.java,
java/awt/image/RescaleOp.java:
Added final keywords where they belong.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/CardLayout.java,
java/awt/Component.java,
java/awt/Font.java,
java/awt/image/SinglePixelPackedSampleModel.java:
Fixed javadocs and argument names all over.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/image/DataBufferShort.java: Fixed file header.
* java/awt/image/DataBufferUShort.java: Likewise.
(DataBufferUShort): Throw NullPointerException if dataArray is null.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/Arc2D.java
(setAngleStart): Corrected (wrong sign on atan2 y parameter).
(setAngles): Likewise.
(containsAngle): Return false on zero extent, don't include
final angle.
(contains): Treat OPEN-type arcs like CHORD ones, not as PIE
ones.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/AffineTransform.java,
(inverseTransform): Fixed bug and simplified code.
(createTransformedShape): Return null on null parameter.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/color/ICC_ColorSpace.java,
java/awt/color/ICC_Profile.java,
java/awt/color/ICC_ProfileGray.java,
java/awt/color/ICC_ProfileRGB.java:
Re-indent copyright header to be standardish.
* java/awt/datatransfer/StringSelection.java:
Reformatted.
* java/awt/geom/Area.java
(EPSILON): Made static.
(RS_EPSILON): Likewise.
(PE_EPSILON): Likewide.
2004-11-30 Sven de Marothy <sven@physto.se>
* javax/swing/SwingUtilities.java:
(computeDifference): Implemented
(computeIntersection): Likewise
(computeUnion): Likewise
(isRectangleContainingRectangle): Likewise
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/BasicStroke.java,
java/awt/Button.java,
java/awt/Canvas.java,
java/awt/CheckboxMenuItem.java,
java/awt/Container.java,
java/awt/EventQueue.java,
java/awt/FileDialog.java,
java/awt/FlowLayout.java,
java/awt/FontMetrics.java,
java/awt/Graphics.java,
java/awt/GridLayout.java,
java/awt/KeyboardFocusManager.java,
java/awt/Label.java,
java/awt/LayoutManager2.java,
java/awt/List.java,
java/awt/MenuBar.java,
java/awt/Scrollbar.java,
java/awt/Toolkit.java,
java/awt/Window.java,
java/awt/datatransfer/DataFlavor.java,
java/awt/datatransfer/FlavorTable.java,
java/awt/event/ActionListener.java,
java/awt/event/HierarchyBoundsAdapter.java,
java/awt/geom/Arc2D.java,
java/awt/geom/Rectangle2D.java,
java/awt/geom/RectangularShape.java,
java/awt/im/spi/InputMethod.java,
java/awt/image/ByteLookupTable.java,
java/awt/image/ColorModel.java,
java/awt/image/DirectColorModel.java,
java/awt/image/ShortLookupTable.java,
java/awt/print/Book.java:
Fixed javadocs and method argument names all over.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GdkFontPeer.java
(buildString): Optimise String building.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/TextArea.java (AccessibleAWTTextArea,
getAccessibleContext): Implement.
* java/awt/TextField.java (AccessibleAWTTextField,
getAccessibleContext): Implement.
2004-11-30 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.lo):
Fixed typo.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Menu.java (AccessibleAWTMenu, getAccessibleContext):
Implement.
* java/awt/PopupMenu.java (AccessibleAWTMenu, getAccessibleContext):
Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/print/PrinterJob.java (lookupPrintServices,
getPrintService, setPrintService): Implement.
(lookupStreamPrintServices): Add commented out implementation.
(printer): New field.
2004-11-30 Mark Wielaard <mark@klomp.org>
* javax/swing/ToolTipManager.java (mouseMoved): Set currentComponent
when not yet set.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/GeneralPath.java (evaluateCrossings):
Fixed epsilon value, should always be nonzero.
2004-11-30 Paul Jenner <psj.home@ntlworld.com>
* java/awt/image/Raster.java
(createPackedRaster): Implemented.
2004-11-30 Graydon Hoare <graydon@redhat.com>
* javax/swing/plaf/basic/BasicTextUI.java:
Listen to focus events, indicate focus via caret.
* javax/swing/text/GapContent.java (getString): Return substring.
* javax/swing/text/PlainDocument.java (reindex): New method.
(createDefaultRoot): Call it.
(insertUpdate): Likewise.
(removeUpdate): Likewise.
* javax/swing/text/Utilities.java (drawTabbedText): Always advance
on tab and newline, even if no painting happens.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* Makefile.am: List peer JNI header: Java source file
dependencies explicitly. Likewise for JNI .lo: JNI header
dependencies.
* Makefile.in: Regenerate.
2004-11-30 Graydon Hoare <graydon@redhat.com>
* Makefile.am: Add entry for BasicTextPaneUI.java
* Makefile.in: Regenerate.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(GdkGraphics2D): Set clip after transform.
(drawImage): Protect against null image.
* gnu/java/awt/peer/gtk/GtkFramePeer.java
(setIconImage): Protect against non-GtkImage args.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(checkImage): Protect against non-GtkImage args.
* java/awt/print/PrinterJob.java:
(print): Add variant taking PrintRequestAttributeSet.
(printDialog): Likewise.
* javax/swing/JComponent.java:
(transferHandler): New field.
(getComponentGraphics): Build new Graphics for each sub-paint.
(getTransferHandler): New method.
(setTransferHandler): New method.
* javax/swing/JDesktopPane.java
(setDragMode): Force LIVE_DRAG_MODE.
* javax/swing/JMenuItem.java
(menuSelectionChanged): Protect against null parent.
* javax/swing/JTable.java (setDefaultRenderer): New method.
* javax/swing/JTree.java: Get basic ctors and UI working.
* javax/swing/JViewport.java (JViewport): Set scroll mode.
* javax/swing/RepaintManager.java
(addDirtyRegion): Skip empty regions.
* javax/swing/ScrollPaneLayout.java (minimumLayoutSize): Do not
bound scrollpane minimum by central view minimum.
* javax/swing/ToolTipManager.java
(showTip): Guard against null component.
* javax/swing/TransferHandler.java: Stub out.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Add entry for TextPaneUI, change Tree icons to pngs.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(installDefaults): Set text position and alignment.
(paintMenuItem): Layout icon with normal compound function.
* javax/swing/plaf/basic/BasicTableHeaderUI.java:
(getMaximumSize): Delete.
(getMinimumSize): Delete.
(getPreferredSize): Use column model's total width.
* javax/swing/plaf/basic/BasicTextPaneUI.java: New file.
* javax/swing/plaf/basic/BasicTextUI.java
(modelChanged): Make resilient against nulls.
* javax/swing/plaf/basic/BasicTreeUI.java:
Add some simplistic config / painting functions.
* javax/swing/plaf/basic/BasicViewportUI.java
(paintSimple): Add new non-backingstore paint mode.
(paintBackingStore): Split out backing store code.
(paint): Switch on painting mode.
* javax/swing/text/SimpleAttributeSet.java
(SimpleAttributeSet): Resist nulls.
* javax/swing/tree/DefaultTreeCellRenderer.java: Implement.
* javax/swing/tree/DefaultTreeModel.java: Partially implement.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c (setFont):
Set pango context's description and language.
2004-11-30 Mark Wielaard <mark@klomp.org>
* java/awt/image/LookupOp.java: Comments and indentation fixes.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Checkbox.java (AccessibleAWTCheckBox): Implement.
(getAccessibleContext): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/TextComponent.java (AccessibleAWTTextComponent):
Implement.
(getIndexAtPoint, getCharacterBounds): New methods.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Button.java (AccessibleAWTButton): Implement.
2004-11-30 Mark Wielaard <mark@klomp.org>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(filenameFilterCallback): Made static.
2004-11-30 Michael Koch <konqueror@gmx.de>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(cairoShowGlyphs) Removed.
2004-11-30 Sven de Marothy <sven@physto.se>
* gnu/java/awt/color/RgbProfileConverter.java (RgbProfileConverter):
Don't invert matrix when reverse CLUT is available.
* gnu/java/awt/color/LinearRGBConverter.java: Documentation update.
* java/awt/color/ICC_ColorSpace.java: Likewise.
* java/awt/color/ICC_Profile.java: Likewise.
* java/awt/color/ICC_ProfileGray.java: Likewise.
* java/awt/color/ICC_ProfileRGB.java: Likewise.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/MenuItem.java (AccessibleAWTMenuItem): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/Choice.java (AccessibleAWTChoice): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/BandedSampleModel.java (scanlineStride): Remove
field hiding ComponentSampleModel.scanlineStride.
2004-11-30 Noa Resare <noa@resare.com>
* java/awt/geom/GeneralPath.java (currentSegment):
Fix typo in transform.transform() invocation.
2004-11-30 Sven de Marothy <sven@physto.se>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(createImage): Created bitmap should be filled with bg color
2004-11-30 Noa Resare <noa@resare.com>
* java/awt/Choice.java (add):
Implement correct selection behavior when peer == null.
(insert): Likewise.
(remove): Likewise.
2004-11-30 Mark Wielaard <mark@klomp.org>
* gnu/java/awt/peer/gtk/GtkChoicePeer.java (GtkChoicePeer):
Call select() when Choice has a selected item.
2004-11-30 Michael Koch <address@bogus.example.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
Fixed method names to start at begin of line. This is desired by GNU
coding style guide.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(gtkWidgetSetVisible): Unused. Removed.
(connectJObject): Likewise.
* gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
(gtkScrolledWindowSetScrollPosition): Commented out.
2004-11-30 Mark Wielaard <mark@klomp.org>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
(Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText): Installed and
renamed from Java_gnu_java_awt_peer_gtk_GdkGlyphVector_setText.
2004-11-30 Mark Wielaard <mark@klomp.org>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
(Java_gnu_java_awt_peer_gtk_GdkGlyphVector_setText): Removed.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(init_dpi_conversion_factor): Correct prototype.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/image/ConvolveOp.java: Added missing
copyright notice.
2004-11-30 Robert Schuster <theBohemian@gmx.net>
Fixes bug #10908
* gnu/java/beans/IntrospectionIncubator.java:
(addMethod): static methods are discarded now, too.
2004-11-30 Mark Wielaard <mark@klomp.org>
* Makefile.am (awt_java_source_files): Add new gnu/java/awt/color
java source files.
* Makefile.in: Regenerated.
2004-11-30 Sven de Marothy <sven@physto.se>
* gnu/java/awt/color/CieXyzConverter.java,
gnu/java/awt/color/GrayScaleConverter.java,
gnu/java/awt/color/SrgbConverter.java,
gnu/java/awt/color/ClutProfileConverter.java,
gnu/java/awt/color/LinearRGBConverter.java,
gnu/java/awt/color/TagEntry.java,
gnu/java/awt/color/ColorLookUpTable.java,
gnu/java/awt/color/ProfileHeader.java,
gnu/java/awt/color/ToneReproductionCurve.java,
gnu/java/awt/color/ColorSpaceConverter.java,
gnu/java/awt/color/PyccConverter.java,
gnu/java/awt/color/GrayProfileConverter.java,
gnu/java/awt/color/RgbProfileConverter.java:
New files.
* java/awt/color/ICC_ColorSpace.java,
java/awt/color/ICC_Profile.java,
java/awt/color/ICC_ProfileGray.java,
java/awt/color/ICC_ProfileRGB.java:
Implemented (sans PhotoYCC color space).
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/AffineTransformOp.java (filter): Implement
bilinear interpolation for Rasters.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java (IndexColorModel): Actually
use the provided colormap. Throw documented exceptions. Document
exceptions.
2004-11-30 Paul Jenner <psj.home@ntlworld.com>
* java/awt/image/IndexColorModel.java (IndexColorModel): Fix
constructor.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/AffineTransformOp.java: Add TYPE_BICUBIC.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/AffineTransformOp.java (filter): Implement Raster
filtering.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentSampleModel.java (getDataElements,
setDataElements): Implement SHORT, FLOAT, and INT transfer types.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Font.java (name): New field.
(size): Likewise.
(style): Likewise.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/Raster.java (createBandedRaster): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ConvolveOp.java: New class.
* Makefile.am: Add ConvolveOp.
* Makefile.in: Regenerate.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/RescaleOp.java (BandCombineOp, ColorConvertOp,
LookupOp, RescaleOp): Fix loop bounds.
2004-11-30 jlquinn <jlquinn@optonline.net>
* Makefile.am: Fix typo in BandCombineOp.
* Makefile.in: Regenerate.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/BandCombineOp.java: New class.
* Makefile.am: Add BandCombineOp.
* Makefile.in: Regenerate.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/LookupOp.java: New class.
* Makefile.am: Add LookupOp.
* Makefile.in: Regenerate.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/SampleModel.java (createSubsetSampleModel): Add
javadocs.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ColorModel.java (cloneColorModel): Fix line
wrap. Use Boolean.valueOf.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(releasePeerGraphicsResource): Fixed typo in method name.
* gnu/java/awt/peer/gtk/GdkFontPeer.java
(finalize): Fixed typo in releasePeerGraphicsResource.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/font/TextAttribute.java
(RUN_DIRECTION_LTR): Initialie with static value instead of
calculating it.
(RUN_DIRECTION_RTL): Likewise.
(STRIKETHROUGH_ON): Likewise.
(SWAP_COLORS_ON): Likewise.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ColorConvertOp.java: New class.
* java/awt/image/ColorModel.java (cloneColorModel): New method.
* Makefile.am: Add ColorConvertOp.
* Makefile.in: Regenerate.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
Track Window focus owner on FOCUS_GAINED events.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
(nativeSetIconImage): Rename to nativeSetIconImageFromDecoder.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c
(Java_gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_nativeRun):
Fix pointer warning.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter):
Fix pointer warning.
* jni/gtk-peer/gtkpeer.h: Introduce widget_union to fix type punned
warnings.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect): Use widget_union
to fix type punned pointer warning.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c (pre_event_handler):
Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(window_get_new_state): Introduce unions to fix warnings as above.
(window_property_changed_cb): Likewise.
(window_active_state_change_cb): Mark unused variables unused.
(window_focus_state_change_cb): Likewise.
(window_focus_in_cb): Likewise.
(window_focus_out_cb): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
(Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont): Convert
PangoFontMap correctly with PANGO_FT2FONT_MAP macro.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JMenuBar.java
(updateUI): Simplified.
* javax/swing/tree/DefaultTreeSelectionModel.java:
Reorganized import statements.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/font/TextAttribute.java,
javax/swing/JComponent.java,
javax/swing/JInternalFrame.java,
javax/swing/table/TableColumn.java,
javax/swing/text/StyleConstants.java:
Replaced "new Boolean(boolean)" with "Boolean.valueOf(boolean)".
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/tree/DefaultTreeCellEditor.java,
javax/swing/tree/DefaultTreeModel.java,
javax/swing/tree/DefaultTreeSelectionModel.java:
Jalopied.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/tree/DefaultTreeCellEditor.java
(EditorContainer.EditorContainer): Fixed arguments.
(EditorContainer.EditorContainer): New method.
(DefaultTextField.DefaultTextField): Fixed arguments, implemented.
(DefaultTextField.getBorder): Implemented.
(listenerList): New field.
(addCellEditorListener): Implemented.
(removeCellEditorListener): Implemented.
(getCellEditorListeners): New method.
* javax/swing/tree/DefaultTreeModel.java
(addTreeModelListener): Fixed javadoc.
(removeTreeModelListener): Likewise.
(getTreeModelListeners): New method.
(fireTreeNodesChanged): Implemented.
(fireTreeNodesInserted): Likewise.
(fireTreeNodesRemoved): Likewise.
(fireTreeStructureChanged): Likewise.
(getListeners): Fixed javadoc.
* javax/swing/tree/DefaultTreeSelectionModel.java
(addTreeSelectionListener): Implemented.
(removeTreeSelectionListener): Likewise.
(fireValueChanged): Likewise.
(getListeners): Likewise.
(addPropertyChangeListener): Likewise.
(removePropertyChangeListener): Likewise.
(getTreeSelectionListeners): New method.
(getPropertyChangeListeners): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicScrollBarUI.java
(maximumThumbSize): Removed static keyword.
(minimumThumbSize): Likewise.
* javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
(CloseAction): Made public.
(IconifyAction): Likewise.
(MaximizeAction): Likewise.
(MoveAction): Likewise.
(RestoreAction): Likewise.
(SizeAction): Likewise.
(SystemMenuBar): Likewise.
* javax/swing/plaf/basic/BasicSliderUI.java
(TrackListener): Likewise.
* javax/swing/plaf/basic/BasicSplitPaneUI.java
(KeyboardDownRightHandler): Likewise.
(KeyboardEndHandler): Likewise.
(KeyboardHomeHandler): Likewise.
(KeyboardResizeToggleHandler): Likewise.
(KeyboardUpLeftHandler): Likewise.
(PropertyHandler): Likewise.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java
(PropertyChangeHandler): Likewise.
(TabSelectionHandler): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/text/JTextComponent.java
(getKeymap): Made public.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JEditorPane.java
(getStream): Throws IOException.
(read): Likewise.
* javax/swing/JRootPane.java
(createContentPane): Fixed return type.
* javax/swing/JSpinner.java
(commitEdit): Throws ParseException.
* javax/swing/plaf/metal/MetalLookAndFeel.java
(serialVersionUID): New field.
* javax/swing/table/TableColumn.java
(resizedPostingDisableCount): Added @deprecated tag.
(disableResizedPosting): Likewise.
(enableResizedPosting): Likewise.
* javax/swing/text/Document.java
(TitleProperty): Fixed value.
* javax/swing/tree/TreeCellEditor.java
(TreeCellEditor): Extends CellEditor.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JWindow.java
javax/swing/SpinnerModel.java
javax/swing/Timer.java
javax/swing/event/MenuKeyEvent.java
javax/swing/plaf/basic/BasicButtonUI.java
javax/swing/plaf/basic/BasicIconFactory.java
javax/swing/plaf/basic/BasicTabbedPaneUI.java
javax/swing/text/AttributeSet.java
javax/swing/text/Highlighter.java
javax/swing/text/StyleConstants.java
javax/swing/tree/TreeCellEditor.java:
Removed redundant and reordered modifiers.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicToolTipUI.java:
Reformatted copyright header.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/AbstractAction.java,
javax/swing/AbstractButton.java,
javax/swing/AbstractCellEditor.java,
javax/swing/AbstractListModel.java,
javax/swing/AbstractSpinnerModel.java,
javax/swing/ActionMap.java,
javax/swing/BorderFactory.java,
javax/swing/Box.java,
javax/swing/ButtonModel.java,
javax/swing/CellEditor.java,
javax/swing/CellRendererPane.java,
javax/swing/DefaultBoundedRangeModel.java,
javax/swing/DefaultButtonModel.java,
javax/swing/DefaultCellEditor.java,
javax/swing/DefaultDesktopManager.java,
javax/swing/DefaultListCellRenderer.java,
javax/swing/DefaultListSelectionModel.java,
javax/swing/DefaultSingleSelectionModel.java,
javax/swing/GrayFilter.java,
javax/swing/InputMap.java,
javax/swing/JApplet.java,
javax/swing/JCheckBoxMenuItem.java,
javax/swing/JColorChooser.java,
javax/swing/JComboBox.java,
javax/swing/JComponent.java,
javax/swing/JDesktopPane.java,
javax/swing/JDialog.java,
javax/swing/JEditorPane.java,
javax/swing/JFileChooser.java,
javax/swing/JFormattedTextField.java,
javax/swing/JFrame.java,
javax/swing/JInternalFrame.java,
javax/swing/JLabel.java,
javax/swing/JLayeredPane.java,
javax/swing/JList.java,
javax/swing/JMenu.java,
javax/swing/JMenuBar.java,
javax/swing/JMenuItem.java,
javax/swing/JOptionPane.java,
javax/swing/JPanel.java,
javax/swing/JPasswordField.java,
javax/swing/JPopupMenu.java,
javax/swing/JRadioButtonMenuItem.java,
javax/swing/JRootPane.java,
javax/swing/JSpinner.java,
javax/swing/JSplitPane.java,
javax/swing/JTabbedPane.java,
javax/swing/JTable.java,
javax/swing/JTextArea.java,
javax/swing/JTextPane.java,
javax/swing/JToggleButton.java,
javax/swing/JToolBar.java,
javax/swing/JToolTip.java,
javax/swing/JTree.java,
javax/swing/JViewport.java,
javax/swing/ListModel.java,
javax/swing/LookAndFeel.java,
javax/swing/MenuSelectionManager.java,
javax/swing/ProgressMonitorInputStream.java,
javax/swing/RepaintManager.java,
javax/swing/RootPaneContainer.java,
javax/swing/ScrollPaneLayout.java,
javax/swing/SpringLayout.java,
javax/swing/SwingUtilities.java,
javax/swing/Timer.java,
javax/swing/ToolTipManager.java,
javax/swing/UIDefaults.java,
javax/swing/UIManager.java,
javax/swing/border/MatteBorder.java,
javax/swing/colorchooser/AbstractColorChooserPanel.java,
javax/swing/colorchooser/ColorSelectionModel.java,
javax/swing/colorchooser/DefaultColorSelectionModel.java,
javax/swing/colorchooser/DefaultHSBChooserPanel.java,
javax/swing/colorchooser/DefaultPreviewPanel.java,
javax/swing/colorchooser/DefaultRGBChooserPanel.java,
javax/swing/colorchooser/DefaultSwatchChooserPanel.java,
javax/swing/event/AncestorEvent.java,
javax/swing/event/HyperlinkEvent.java,
javax/swing/event/InternalFrameEvent.java,
javax/swing/event/MenuDragMouseEvent.java,
javax/swing/event/TableColumnModelEvent.java,
javax/swing/event/TableModelEvent.java,
javax/swing/event/TreeExpansionEvent.java,
javax/swing/event/TreeModelEvent.java,
javax/swing/event/TreeSelectionEvent.java,
javax/swing/event/TreeWillExpandListener.java,
javax/swing/event/UndoableEditEvent.java,
javax/swing/filechooser/FileView.java,
javax/swing/plaf/BorderUIResource.java,
javax/swing/plaf/ComponentUI.java,
javax/swing/plaf/FileChooserUI.java,
javax/swing/plaf/IconUIResource.java,
javax/swing/plaf/ListUI.java,
javax/swing/plaf/PopupMenuUI.java,
javax/swing/plaf/SplitPaneUI.java,
javax/swing/plaf/TabbedPaneUI.java,
javax/swing/plaf/TextUI.java,
javax/swing/plaf/TreeUI.java,
javax/swing/plaf/basic/BasicArrowButton.java,
javax/swing/plaf/basic/BasicBorders.java,
javax/swing/plaf/basic/BasicButtonUI.java,
javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java,
javax/swing/plaf/basic/BasicColorChooserUI.java,
javax/swing/plaf/basic/BasicComboBoxEditor.java,
javax/swing/plaf/basic/BasicComboBoxRenderer.java,
javax/swing/plaf/basic/BasicComboBoxUI.java,
javax/swing/plaf/basic/BasicComboPopup.java,
javax/swing/plaf/basic/BasicDesktopIconUI.java,
javax/swing/plaf/basic/BasicDesktopPaneUI.java,
javax/swing/plaf/basic/BasicIconFactory.java,
javax/swing/plaf/basic/BasicInternalFrameTitlePane.java,
javax/swing/plaf/basic/BasicInternalFrameUI.java,
javax/swing/plaf/basic/BasicListUI.java,
javax/swing/plaf/basic/BasicLookAndFeel.java,
javax/swing/plaf/basic/BasicMenuBarUI.java,
javax/swing/plaf/basic/BasicMenuItemUI.java,
javax/swing/plaf/basic/BasicMenuUI.java,
javax/swing/plaf/basic/BasicOptionPaneUI.java,
javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java,
javax/swing/plaf/basic/BasicPopupMenuUI.java,
javax/swing/plaf/basic/BasicProgressBarUI.java,
javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java,
javax/swing/plaf/basic/BasicRootPaneUI.java,
javax/swing/plaf/basic/BasicScrollBarUI.java,
javax/swing/plaf/basic/BasicSeparatorUI.java,
javax/swing/plaf/basic/BasicSliderUI.java,
javax/swing/plaf/basic/BasicSpinnerUI.java,
javax/swing/plaf/basic/BasicSplitPaneDivider.java,
javax/swing/plaf/basic/BasicSplitPaneUI.java,
javax/swing/plaf/basic/BasicTabbedPaneUI.java,
javax/swing/plaf/basic/BasicTableHeaderUI.java,
javax/swing/plaf/basic/BasicTableUI.java,
javax/swing/plaf/basic/BasicTextAreaUI.java,
javax/swing/plaf/basic/BasicTextFieldUI.java,
javax/swing/plaf/basic/BasicTextUI.java,
javax/swing/plaf/basic/BasicToolBarSeparatorUI.java,
javax/swing/plaf/basic/BasicToolBarUI.java,
javax/swing/plaf/basic/BasicToolTipUI.java,
javax/swing/plaf/basic/BasicTreeUI.java,
javax/swing/plaf/basic/BasicViewportUI.java,
javax/swing/plaf/basic/ComboPopup.java,
javax/swing/table/AbstractTableModel.java,
javax/swing/table/DefaultTableCellRenderer.java,
javax/swing/table/DefaultTableColumnModel.java,
javax/swing/table/DefaultTableModel.java,
javax/swing/table/JTableHeader.java,
javax/swing/table/TableCellEditor.java,
javax/swing/table/TableCellRenderer.java,
javax/swing/table/TableColumn.java,
javax/swing/table/TableColumnModel.java,
javax/swing/text/AbstractDocument.java,
javax/swing/text/Caret.java,
javax/swing/text/DefaultCaret.java,
javax/swing/text/DefaultEditorKit.java,
javax/swing/text/DefaultHighlighter.java,
javax/swing/text/EditorKit.java,
javax/swing/text/JTextComponent.java,
javax/swing/text/LayeredHighlighter.java,
javax/swing/text/PasswordView.java,
javax/swing/text/SimpleAttributeSet.java,
javax/swing/text/StyleConstants.java,
javax/swing/text/StyleContext.java,
javax/swing/text/StyledEditorKit.java,
javax/swing/text/TextAction.java,
javax/swing/text/View.java,
javax/swing/tree/AbstractLayoutCache.java,
javax/swing/tree/DefaultTreeCellRenderer.java,
javax/swing/tree/DefaultTreeModel.java,
javax/swing/tree/DefaultTreeSelectionModel.java,
javax/swing/tree/FixedHeightLayoutCache.java,
javax/swing/tree/TreeCellRenderer.java,
javax/swing/tree/TreeSelectionModel.java,
javax/swing/tree/VariableHeightLayoutCache.java,
javax/swing/undo/AbstractUndoableEdit.java,
javax/swing/undo/UndoableEditSupport.java:
Imports cleaned up.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/Container.java,
java/awt/Font.java,
java/awt/font/TextLayout.java:
Imports cleaned up.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/AbstractButton.java
(getLabel): Added @deprecated tag.
(setLabel): Likewise.
* javax/swing/FocusManager.java
(disableSwingFocusManager): Likewise.
(isFocusManagerEnabled): Likewise.
* javax/swing/JComponent.java
(isManagingFocus): Added version to @deprecated tag.
(getNextFocusableComponent): Moved @deprecated tag to bottom of
javadoc.
(getConditionForKeyStroke): Likewise.
(getActionForKeyStroke): Likewise.
* javax/swing/JDesktopPane.java
(LIVE_DRAG_MODE): Added @specnote tag.
(OUTLINE_DRAG_MODE): Likewise.
* javax/swing/JInternalFrame.java
(MENU_BAR_PROPERTY): Fixed value.
(getMenuBar): Added @deprecated tag.
(setMenuBar): Likewise.
* javax/swing/JViewport.java
(isBackingStoreEnabled): Likewise.
(setBackingStoreEnabled): Likewise.
* javax/swing/plaf/basic/BasicDesktopPaneUI.java
(closeKey): Likewise.
(maximizeKey): Likewise.
(minimizeKey): Likewise.
(navigateKey): Likewise.
(navigateKey2): Likewise.
* javax/swing/plaf/basic/BasicInternalFrameUI.java
(openMenuKey): Likewise.
* javax/swing/plaf/basic/BasicSplitPaneUI.java
(keyboardDownRightListener): Likewise.
(keyboardEndListener): Likewise.
(keyboardHomeListener): Likewise.
(keyboardResizeToggleListener): Likewise.
(keyboardUpLeftListener): Likewise.
(dividerResizeToggleKey): Likewise.
(downKey): Likewise.
(endKey): Likewise.
(homeKey): Likewise.
(leftKey): Likewise.
(rightKey): Likewise.
(upKey): Likewise.
(createKeyboardUpLeftListener): Likewise.
(createKeyboardDownRightListener): Likewise.
(createKeyboardHomeListener): Likewise.
(createKeyboardEndListener): Likewise.
(createKeyboardResizeToggleListener): Likewise.
(getDividerBorderSize): Likewise.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java
(downKey): Likewise.
(leftKey): Likewise.
(rightKey): Likewise.
(upKey): Likewise.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
(Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create): Use the
GTK_TEXT_VIEW macro.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(connect_awt_hook_cb): Mark unused variable unused.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c (selection_get):
Do the cast right.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
(Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create): According to
the gtk API gtk_combo_box_new_text actually returns a GtkWidget.
Remove unused var menu.
(selection_changed): Remove unused value.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(Java_gnu_java_awt_peer_gtk_GtkButtonPeer_setNativeBounds): Fix pointer
warning with using an intermediate variable.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
(area_updated): Fix unused var warning for BE archs.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals): Remove unused
var.
(realize_cb): Mark unused variable unused.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
(seek_glyphstring_idx): Fix a C90 warning.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c
(Java_gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_nativeRun):
Mark unused arguments unused.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
(Java_gnu_java_awt_peer_gtk_GdkGlyphVector_initState),
(Java_gnu_java_awt_peer_gtk_GdkGlyphVector_setGlyphCodes),
(Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphCharIndex),
(Java_gnu_java_awt_peer_gtk_GdkGlyphVector_glyphIsHorizontal):
Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c
(Java_gnu_java_awt_peer_gtk_GdkFontMetrics_getPeerFontMetrics),
(Java_gnu_java_awt_peer_gtk_GdkFontMetrics_getPeerTextMetrics):
Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_nativeSetFilenameFilter):
Likewise.
(filenameFilterCallback): Remove unused var.
(handle_response): Declare str_fileName and remove last else statement.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c:
New File.
(nativeGetNumFontsFamilies) New function.
(nativeGetFontFamilies) Likewise.
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
(getAvailableFontFamilyNames): Implement.
* Makefile.am (gtk_c_source_files): Add GdkGraphicsEnvironment.c.
* Makefile.in: Regenerate.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/ClasspathFontPeer.java
(setStandardAttributes(String,Map)): If size attribute doesn't
exist, default to size 12. Clamp size value to a minimum of 1.
2004-11-30 Jeroen Frijters <jeroen@frijters.net>
* javax/swing/JDialog.java
(decorated): Likewise.
* javax/swing/JFrame.java
(defaultLookAndFeelDecorated): Likewise.
2004-11-30 Jeroen Frijters <jeroen@frijters.net>
* javax/swing/plaf/basic/BasicToolBarUI.java
(offset, regular): Made final.
* javax/swing/plaf/basic/BasicScrollBarUI.java
(DECREASE_HIGHLIGHT, INCREASE_HIGHLIGHT, NO_HIGHLIGHT,
POSITIVE_SCROLL, NEGATIVE_SCROLL): Made final.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/BitwiseXORComposite.java,
gnu/java/awt/ClasspathToolkit.java,
gnu/java/awt/image/XBMDecoder.java,
gnu/java/awt/peer/GLightweightPeer.java,
gnu/java/awt/peer/gtk/GdkGlyphVector.java:
Reorganized import statements.
2004-11-30 Jeroen Frijters <jeroen@frijters.net>
* java/awt/Button.java
(next_button_number): Removed useless initializer.
* java/awt/Frame.java
(next_frame_number): Likewise.
* java/awt/Panel.java
(next_panel_number): Likewise,
* java/awt/Scrollbar.java
(next_scrollbar_number): Likewise.
* java/awt/TextArea.java
(next_text_number): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/image/ByteLookupTable.java
(ByteLookupTable) :Fixed HTML entities in javadocs.
(lookupPixel): Fix case when dst is null.
* java/awt/image/ShortLookupTable.java
(ShortLookupTable) :Fixed HTML entities in javadocs.
(lookupPixel): Fix case when dst is null.
* java/awt/image/DataBufferByte.java,
java/awt/image/DataBufferDouble.java,
java/awt/image/DataBufferFloat.java,
java/awt/image/DataBufferInt.java,
java/awt/image/DataBufferShort.java,
java/awt/image/DataBufferUShort.java:
Fix initialization of bankData in constructors.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(setNativeBounds): Set GtkEventBox, GtkButton and GtkLabel size
requests.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(setNativeBounds): Make package private. Set size request even
if GTK parent is NULL.
* gnu/java/awt/peer/gtk/GtkLabelPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
(setNativeBounds): Set GtkEventBox and GtkLabel size requests.
2004-11-30 Mark Wielaard <mark@klomp.org>
Workaround for bug #17952.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(request_frame_extents): Check window->window != NULL.
2004-11-30 Mark Wielaard <mark@klomp.org>
* jni/gtk-peer/gdkfont.h: Include gtkpeer.h not gtkcairopeer.h.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: Use
native_text_layout_state_table here.
* jni/gtk-peer/gdkfont.h: Mark native_text_layout_state_table extern.
2004-11-30 Mark Wielaard <mark@klomp.org>
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
(setChars): Only call pango_itemize() when vec->glyphitems != NULL.
Only call pango_shape() when gi->glyphs->num_glyphs > 0.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GtkToolkit.java:
Merged import statements.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(isBufferedImageGraphics): Simplified.
2004-11-30 Paul Jenner <psj.home@ntlworld.com>
* javax/swing/JTree.java
(isRootVisible): Fixed typo in method name.
* javax/swing/JScrollBar.java
(setValues): Likewise.
* javax/swing/JScrollPane.java
(createScrollListener): Call JScrollBar.setValues.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkContainerPeer.java (endValidate):
Don't call setParentAndBounds on GtkWindowPeers.
* java/awt/Component.java (static): Don't set default keyboard
focus manager.
* java/awt/KeyboardFocusManager.java
(getCurrentKeyboardFocusManager): If current keyboard focus
manager is null set a default.
* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(gtkWidgetSetBackground): New method.
(block_expose_events_cb): New function.
(connectSignals): Block the AWT's expose event processing on
button press and release.
(gtkSetLabel): Set text on proper widget.
(gtkWidgetModifyFont): Modify font on proper widget.
(gtkWidgetSetBackground): Set normal, active and prelight
colours.
(gtkWidgetSetForeground): Set forground colour of proper widget.
(gtkActivate): Activate the correct widget.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (clearRect):
Only clear rectangle if the backing component is not an event
box.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(beginNativeRepaintID): New variable.
(endNativeRepaintID): Likewise.
(gtkInit): Initialize new fields with method IDs.
* jni/gtk-peer/gtkpeer.h (beginNativeRepaintID): Declare extern.
(endNativeRepaintID): Likewise.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* javax/swing/JList.java (init): Revert accidental commit.
* gnu/java/awt/peer/gtk/GdkGraphics.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (GdkGraphics):
Call initComponentGraphics or connectSignals depending on
component's realization status.
(realize_cb): New function.
(initComponentGraphics): New method.
(connectSignals): New method.
(clipRect): Return immediately if component is not realized.
(setClip): Likewise.
(translate): Likewise.
(drawImage variants): Return false immediately if component is
not realized.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(connectSignals): New method.
(GdkGraphics2D): Call initComponentGraphics2D or connectSignals
depending on component's realization status. Move other
initialization calls to ...
(initComponentGraphics2D): New method.
(realize_cb): New function.
(cairoSetMatrix): Return immediately if gr is NULL.
(cairoNewPath): Likewise.
(cairoRectangle): Likewise.
(cairoClip): Likewise.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(gtkWidgetRepaintArea): Remove method.
(isRealized): New method.
(GtkComponentPeer): Move setParent, connectJObject and setCursor
calls to setParentAndBounds. Call setParentAndBounds.
(setParentAndBounds): New method.
(setComponentBounds): Return immediately if bounds are all zero.
(repaint): Remove call to gtkWidgetRepaintArea. Return
immediately if requested paint region is 0x0.
(setCursor): New method.
(gtkWidgetSetParent): Only set widget's parent if its parent is
currently NULL.
(setNativeBounds): Only set widget's bounds if it has a parent.
(connectSignals): Don't call gtk_widget_realize. Connect
"realize" signal to connect_awt_hook_cb handler.
* gnu/java/awt/peer/gtk/GtkContainerPeer.java (isValidating):
New field.
(beginValidate): Set isValidating true.
(endValidate): Set parents and bounds for children first, then
for this. Set isValidating false.
* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(connectJObject): Remove method.
(connectSignals): Don't call gtk_widget_realize.
* gnu/java/awt/peer/gtk/GtkListPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
(connectJObject): Remove method.
(connectSignals): Don't call gtk_widget_realize.
* gnu/java/awt/peer/gtk/GtkPanelPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c
(connectJObject): Remove method.
* gnu/java/awt/peer/gtk/GtkScrollbarPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c
(connectJObject): Remove method.
* gnu/java/awt/peer/gtk/GtkWindowPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(create): Don't call gtk_widget_realize.
(connectJObject): Remove method.
(connectSignals): Don't call gtk_widget_realize. Connect
"realize" signal to connect_awt_hook_cb handler.
(nativeSetBounds): Don't attempt to move GDK window if it is
NULL.
* java/awt/Container.java (addImpl): Don't call comp.addNotify
if peer is not null.
(validateTree): Create peers for all children before calling
doLayout.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(connectSignals): Don't call gtk_widget_realize.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(connect_awt_hook_cb): New function.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(initComponentGraphicsID): New variable.
(initComponentGraphics2DID): Likewise.
(setCursorID): Likewise.
(gtkInit): Initialize new fields with method IDs.
* jni/gtk-peer/gtkpeer.h (initComponentGraphicsID): Declare
extern.
(initComponentGraphics2DID): Declare extern.
(setCursorID): Likewise.
(connect_awt_hook_cb): Declare function.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java,
gnu/java/awt/peer/gtk/GdkGlyphVector.java,
gnu/java/awt/peer/gtk/GdkGraphics2D.java,
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,
gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,
gnu/java/awt/peer/gtk/GtkButtonPeer.java,
gnu/java/awt/peer/gtk/GtkClipboard.java,
gnu/java/awt/peer/gtk/GtkDialogPeer.java,
gnu/java/awt/peer/gtk/GtkFileDialogPeer.java,
gnu/java/awt/peer/gtk/GtkFontPeer.java,
gnu/java/awt/peer/gtk/GtkListPeer.java,
gnu/java/awt/peer/gtk/GtkMenuItemPeer.java,
gnu/java/awt/peer/gtk/GtkToolkit.java,
gnu/java/awt/peer/gtk/GtkWindowPeer.java:
Import statements reworked. Some little reformattings.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/image/AffineTransformOp.java
(TYPE_BILINEAR): Initialize with 2.
* java/awt/print/Printable.java: Jalopied.
(PAGE_EXISTS): Initialize with 0;
(NO_SUCH_PAGE): Initialized with 1.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* Makefile.am: Add BufferedImageFilter.java.
* Makefile.in: Regenerate.
2004-11-30 Graydon Hoare <graydon@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(install_font_peer): Minor bug fixes to track cairo font semantics.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/BufferedImageFilter.java: Implement.
2004-11-30 Graydon Hoare <graydon@redhat.com>
* Makefile.am
(jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c)
(jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c)
(gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java)
(gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.java): Remove.
(jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c)
(jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c)
(gnu/java/awt/peer/gtk/GdkTextLayout.java)
(gnu/java/awt/peer/gtk/GdkFontPeer.java)
(gnu/java/awt/peer/ClasspathTextLayoutPeer.java): Add
* Makefile.in: Regenerate.
* gnu/awt/xlib/XToolkit.java
(getClasspathTextLayoutPeer): Add stub.
* gnu/java/awt/ClasspathToolkit.java
(getClasspathTextLayoutPeer) Add.
* gnu/java/awt/peer/ClasspathFontPeer.java
(copyStyleToAttrs)
(copySizeToAttrs): Make public.
* gnu/java/awt/peer/ClasspathTextLayoutPeer.java: New file.
* gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java: Remove.
* gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.java: Remove.
* gnu/java/awt/peer/gtk/GdkFontMetrics.java: Rewrite.
* gnu/java/awt/peer/gtk/GdkFontPeer.java: New file.
* gnu/java/awt/peer/gtk/GdkGlyphVector.java: Adjust type names.
* gnu/java/awt/peer/gtk/GdkGraphics.java
(getFontPeer): New function.
(drawString): Pass font peer to native side.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java
(cairoSetFont)
(cairoShowGlyphs)
(PainterThread): Remove.
(GdkGraphics2D): Set hints during construction.
(shifted)
(walkPath)
(draw)
(setRenderingHint)
(setRenderingHints): Reimplement normalization logic.
(getDefaultHints)
(updateBufferedImage)
(isBufferedImageGraphics)
(updateImagePixels)
(drawImage): Make final.
(drawImage): Always paint synchronously.
(drawString)
(drawGlyphVector): Rewrite.
(releasePeerGraphicResource)
(getPeerTextMetrics)
(getPeerFontMetrics)
(drawGdkGlyphVector)
(drawGdkTextLayout)
(cairoDrawGdkGlyphVector)
(cairoDrawGdkTextLayout)
(cairoDrawString)
(getFontPeer): New functions.
* gnu/java/awt/peer/gtk/GdkTextLayout.java: New file.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(getFontMetrics): Get metrics via toolkit, to hit cache.
* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java: Use getFontMetrics.
* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Likewise.
* gnu/java/awt/peer/gtk/GtkToolkit.java (LRUCache): New class.
(fontCache)
(metricsCache)
(imageCache): New members.
(getFontMetrics)
(getImage)
(getClasspathFontPeer): Use caches.
(getFontPeer): Route through getClasspathFontPeer.
* java/awt/Font.java (attrsToMap): Remove, adjust ctors.
* java/awt/font/TextLayout.java: Implement in terms of peer.
* javax/swing/plaf/basic/BasicSliderUI.java
(paintThumb): Use polyline rather than polygon.
* javax/swing/plaf/basic/BasicGraphicsUtils.java:
Update comment but, alas, still do not switch to using TextLayouts.
* javax/swing/text/Utilities.java (drawTabbedText):
Draw text run-at-a-time, not char-at-a-time.
* jni/gtk-peer/gdkfont.h: Publicize some of the font interface, add
layout table.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c:
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c:
Remove files.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c: Rewrite to
incorporate brains of old GdkClasspathFontPeerMetrics.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c: Rewrite to
incorporate brains of old GdkClasspathFontPeer.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c: New file.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
(drawString): Rewrite to use persistent layout in peer font.
Comment out extraneous gdk_flush calls.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(metrics_cairo)
(metrics_surface): New static variables.
(paint_glyph_run)
(install_font_peer): New helper functions.
(releasePeerGraphicResource)
(getPeerTextMetrics)
(getPeerFontMetrics)
(cairoDrawGdkTextLayout)
(cairoDrawGdkGlyphVector): New native methods.
(cairoDrawString): Rewrite, leaving layout-based version
commented out for the time being.
* jni/gtk-peer/gtkpeer.h (graphics): Add fields for pango stuff.
2004-11-30 David Gilbert <david.gilbert@object-refinery.com>
* java/awt/geom/AffineTransform.java:
Fixed javadocs overall.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentColorModel.java: Remove FIXME comment since
it's correct.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java: Fix use of immutable
BigIntegers.
2004-11-30 Tom Tromey <tromey@redhat.com>
* javax/swing/plaf/basic/BasicOptionPaneUI.java (MessageIcon):
Renamed from 'messageIcon'.
(errorIcon, infoIcon, warningIcon, questionIcon): Updated.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/RescaleOp.java: Fix formatting.
2004-11-30 Olga Rodimina <rodimina@redhat.com>
* javax/swing/plaf/basic/BasicComboPopup.java
(SCROLL_DOWN): made final.
(SCROLL_UP): made final.
2004-11-30 Olga Rodimina <rodimina@redhat.com>
* javax/swing/plaf/basic/BasicComboPopup.java:
Added javadocs for undocumented fields.
(show): scroll down to the selected item and
highlight selected item.
(startAutoScrolling): Implemented.
(stopAutoScrolling): Implemented.
(autoScrollUp): Implemented.
(autoScrollDown): Implemented.
(InvocationMouseHandler.mouseReleased): Implemented.
(InvocationMouseMotionHandler.mouseDragged): Implemented.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/RescaleOp.java: Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java (getRGBs,
convertToIntDiscrete): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java: Add class docs.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java (isValid, getValidPixels):
Implement.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/MenuBar.java,
java/awt/peer/MenuBarPeer.java:
Revert accidentally commited changes.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/AWTKeyStroke.java,
java/awt/Canvas.java,
java/awt/CardLayout.java,
java/awt/CheckboxMenuItem.java,
java/awt/Component.java,
java/awt/Container.java,
java/awt/DefaultKeyboardFocusManager.java,
java/awt/EventDispatchThread.java,
java/awt/FileDialog.java,
java/awt/FlowLayout.java,
java/awt/Font.java,
java/awt/Frame.java,
java/awt/Graphics2D.java,
java/awt/GraphicsEnvironment.java,
java/awt/GridBagConstraints.java,
java/awt/GridBagLayout.java,
java/awt/GridLayout.java,
java/awt/Image.java,
java/awt/KeyboardFocusManager.java,
java/awt/Label.java,
java/awt/List.java,
java/awt/MediaTracker.java,
java/awt/Menu.java,
java/awt/MenuBar.java,
java/awt/MenuComponent.java,
java/awt/Panel.java,
java/awt/PopupMenu.java,
java/awt/ScrollPane.java,
java/awt/Scrollbar.java,
java/awt/SystemColor.java,
java/awt/TextArea.java,
java/awt/TextField.java,
java/awt/Toolkit.java,
java/awt/Window.java,
java/awt/color/ICC_Profile.java,
java/awt/datatransfer/DataFlavor.java,
java/awt/datatransfer/StringSelection.java,
java/awt/datatransfer/SystemFlavorMap.java,
java/awt/dnd/Autoscroll.java,
java/awt/dnd/DropTarget.java,
java/awt/dnd/DropTargetContext.java,
java/awt/dnd/DropTargetDragEvent.java,
java/awt/dnd/peer/DropTargetContextPeer.java,
java/awt/event/AdjustmentEvent.java,
java/awt/event/InputEvent.java,
java/awt/event/InvocationEvent.java,
java/awt/event/KeyEvent.java,
java/awt/event/MouseEvent.java,
java/awt/font/TextLayout.java,
java/awt/geom/GeneralPath.java,
java/awt/geom/Point2D.java,
java/awt/im/InputContext.java,
java/awt/im/spi/InputMethodContext.java,
java/awt/image/AffineTransformOp.java,
java/awt/image/BufferedImage.java,
java/awt/image/ColorModel.java,
java/awt/image/ComponentColorModel.java,
java/awt/image/CropImageFilter.java,
java/awt/image/DirectColorModel.java,
java/awt/image/MemoryImageSource.java,
java/awt/image/PackedColorModel.java,
java/awt/image/PixelGrabber.java,
java/awt/image/RasterOp.java,
java/awt/peer/MenuBarPeer.java:
Some fixes for checkstyle. Import statement and modifier order
redordering.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JTable.java
(setModel): Reimplemented.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextArea.java
(append): Re-implemented.
(insert): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JSpinner.java
(serialVersionUID): New static field.
* javax/swing/JToggleButton.java
(JToggleButton): Fixed email addresses.
* javax/swing/SpinnerNumberModel.java
(serialVersionUID): Added javadoc.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextArea.java:
Don't use JTextComponent.doc directly. GCJ from java-gui-branch has a
bug here which is fixed in HEAD ...
2004-11-30 Andrew John Hughes <address@hidden>
* javax/swing/JTextArea.java: Added additional
documentation.
2004-11-30 Andrew John Hughes <address@hidden>
* javax/swing/JRadioButton.java:
Implemented additional constructors and accessibility
classes. Added documentation and fixed a typo in
AbstractButton.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/IndexColorModel.java (IndexColorModel): Implement
missing constructor.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentColorModel.java (ComponentColorModel):
Implement missing 1.4 constructor.
2004-11-30 Andrew John Hughes <address@hidden>
* javax/swing/JToggleButton.java:
Implemented additional constructors and accessibility
classes. Added documentation and fixed a typo in
AbstractButton.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ColorModel.java (getDataElement,
getDataElements): Document since 1.4.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/BandedSampleModel.java: Implement.
* Makefile.am: Add java/awt/image/BandedSampleModel.java.
* Makefile.in: Regenerated.
2004-11-30 Michael Koch <konqueror@gmx.de>
* java/awt/Window.java: Fixed whitespace difference with GNU
classpath.
2004-11-30 Mark Wielaard <mark@klomp.org>
* Makefile.am: Add javax/swing/SpinnerListModel.java.
* Makefile.in: Regenerated.
2004-11-30 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/swing/SpinnerListModel.java, javax/swing/SpinnerModel.java
Implemented SpinnerListModel. Added documentation to
SpinnerModel.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(init_dpi_conversion_factor): Apply the patch from main correctly.
2004-06-26 Andreas Tobler <a.tobler@schweiz.ch>
2004-11-30 Tom Tromey <tromey@redhat.com>
Bug 9948.
* javax/swing/JDesktopPane.java (LIVE_DRAG_MODE): Now final.
(OUTLINE_DRAG_MODE): LIVE_DRAG_MODE.
* javax/swing/plaf/basic/BasicSplitPaneUI.java
(NON_CONTINUOUS_DIVIDER): Now final. Initialize.
2004-11-30 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/Canvas.java
(AccessibleAWTCanvas): added serialization UID
* java/awt/Label.java
(AccessibleAWTLabel): added serialization UID
* javax/swing/JRootPane.java
(AccessibleJRootPane): added comment to existing UID
* javax/swing/JSpinner.java
(DefaultEditor): added serialization UID
(NumberEditor): added serialization UID
* javax/swing/text/html/HTML.java
(UnknownTag): added serialization UID
2004-11-30 Jeroen Frijters <jeroen@frijters.net>
* javax/swing/JInternalFrame.java
(CONTENT_PANE_PROPERTY,FRAME_ICON_PROPERTY,GLASS_PANE_PROPERTY,
IS_CLOSED_PROPERTY,IS_ICON_PROPERTY,IS_MAXIMUM_PROPERTY,
IS_SELECTED_PROPERTY,LAYERED_PANE_PROPERTY,MENU_BAR_PROPERTY,
ROOT_PANE_PROPERTY,TITLE_PROPERTY): Made final as per API spec.
* javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
(CLOSE_CMD,ICONIFY_CMD,MAXIMIZE_CMD,MOVE_CMD,RESTORE_CMD,SIZE_CMD):
Made final as per API spec.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gtkpeer.h: Remove duplicated copyright string.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/Arc2D.java: Reformatted.
(setArc): Correct documentation to say 'upper left corner'.
(setArcByTangent,contains,intersects): Implemented.
(containsAngle): Corrected to handle negative extents.
(ArcIterator): Set to private.
(ArcIterator): Corrected for CHORD-type arcs, negative extents.
(intersects): Fix: Now checks the arc segment.
(contains): Cleaned up.
* java/awt/geom/CubicCurve2a.javaD: Fix insideness-test. Reindent.
(contains): Implemented.
(intersects): Implemented.
* java/awt/geom/QuadCurve2D.java: Fix insideness-test. Reindent.
* java/awt/geom/GeneralPath: Fix insideness-test. Reindent and
document. Fully (re)implemented using separate xpoints and ypoints
float[] coords.
2004-11-30 Andreas Tobler <a.tobler@schweiz.ch>
* configure.ac: Introduce AC_C_BIGENDIAN_CROSS for WORDS_BIGENDIAN.
* configure: Regenerate.
* include/config.h.in: Likewise.
* jni/gtk-peer/gtkpeer.h (SWAPU32): Introduce macro to swap pixels.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c: Moved SWAPU32
macro to gtkpeer.h.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels): Convert
pixels from 0xBBGGRRAA to 0xAARRGGBB only on Little Endian
architectures.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c (area_updated):
Likewise.
2004-11-30 David Gilbert <david.gilbert@object-refinery.com>
* java/awt/SystemColor.java: Fix @link doc entries.
2004-11-30 David Gilbert <david.gilbert@object-refinery.com>
* java/awt/RenderingHints.java: Documented.
(RenderingHints): Accept null init Map.
(putAll): Preprocess map to generate appropriate exceptions.
(remove): Cast object to Key and remove from hintMap.
2004-11-30 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/MenuComponent.java, java/awt/MenuBar.java:
Implementation of accessibility classes and methods
for these two components.
2004-11-30 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/KeyboardFocusManager.java:
Added missing documentation.
2004-11-30 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/awt/Label.java, java/awt/Canvas.java:
Added accessibility classes to AWT Label and Canvas,
as well as additional documentation for Canvas.
2004-11-30 David Gilbert <address@bogus.example.com>
* java/awt/image/DataBuffer.java: Update API documentation.
* java/awt/image/DataBufferByte.java: Likewise.
* java/awt/image/DataBufferDouble.java: Likewise.
* java/awt/image/DataBufferFloat.java: Likewise.
* java/awt/image/DataBufferInt.java: Likewise.
* java/awt/image/DataBufferShort.java: Likewise.
* java/awt/image/DataBufferUShort.java: Likewise.
2004-11-30 Dalibor Topic <robilad@kaffe.org>
* java/awt/Component.java (postEvent):
Only delegate to parent if a parent exists.
Reported by: Stephane Meslin-Weber <steph@tangency.co.uk>
2004-11-30 Sven de Marothy <sven@physto.se>
*java/awt/AWTEventMulticaster.java,
java/awt/Adjustable.java,
java/awt/Point.java,
java/awt/Polygon.java,
java/awt/Rectangle.java,
java/awt/Shape.java,
java/awt/geom/Area.java,
java/awt/geom/Ellipse2D.java,
java/awt/geom/PathIterator.java,
java/awt/geom/Point2D.java,
java/awt/geom/Rectangle2D.java,
java/lang/Comparable.java,
java/util/Arrays.java:
Fixed documentation errors
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentSampleModel.java: Add documentation.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentSampleModel.java (constructor):
Initialize numBanks when figuring out the max bank index.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/Raster.java (createPackedRaster): Implement
MultiPixelPackedSampleModel codepath.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/MultiPixelPackedSampleModel.java: Implement.
* Makefile.am: Add MultiPixelPackedSampleModel.java.
* Makefile.in: Regenerate.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/Raster.java (getNumBands): Implement.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/Raster.java
(createPackedRaster(int,int,int,int,int,Point)): Implement for
bands>1.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/SinglePixelPackedSampleModel.java
(SinglePixelPackedSampleModel): Throw exception for unsupported
datatype.
2004-11-30 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ColorModel.java (getDataElement): Implemented.
Update javadoc.
(getDataElements): Add missing version. Remove bogus version.
Update javadoc.
2004-11-30 Olga Rodimina <rodimina@redhat.com>
* javax/swing/plaf/basic/BasicComboBoxUI.java:
(paintCurrentValue): Pass correct parameters to
getListCellRendererComponent().
(ListDataHandler.intervalRemoved): Implemented.
(PropertyChangeHandler.propertyChange): Handle changes in
MODEL_CHANGED_PROPERTY of the JComboBox
* javax/swing/plaf/basic/BasicComboPopup.java:
(BasicComboPopup): Moved code that configures popup to
configurePopup() and call it instead.
(firePopupMenuWillBecomeVisible): Implemented.
(firePopupMenuWillBecomeInvisible): Likewise.
(firePopupMenuCanceled): Likewise.
(configureList): Set list's visibleRowCount same as
comboBox's visibleRowCount.
(configurePopup): Implemented.
(getPopupHeightForRowCount): Get item's from JComboBox's model and
not from model of the JList.
(ListMouseMotionHandler.mouseMoved): Implemented.
(PropertyChangeHandler.propertyChange): Handles change in the
JComboBox's model.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JComponent.java
(isMaximumSizeSet): New method.
(isMinimumSizeSet): Likewise.
(isPreferredSizeSet): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JSpinner.java:
Some Re-formatting.
(spinner): New field.
(DefaultEditor): New method.
(getSpinner): Likewise.
(NumberEdito): Likewise.
(getModel): Likewise
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/InputVerifier.java:
Re-formatted.
* javax/swing/JComponent.java
(inputVerifier): New property field.
(getInputVerifier): New method.
(setInputVerifier): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JComponent.java
(JComponent): Added javadoc comment.
(setBorder): Fire property change eventr.
(setEnabled): Likewise.
(setMaximumSize): Likewise.
(setMinimumSize): Likewise.
(setPreferredSize): Likewise.
(setOpaque): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextField.java
(action): New field.
(actionCommand): Likewise.
(actionPropertyChangeListener): Likewise.
(setHorizontalAlignment): Abort soon if new value == old value. Fire
event before repainting.
(postActionEvent): New method.
(getAction): Likewise.
(setAction): Likewise.
(getActionCommand): Likewise.
(setActionCommand): Likewise.
(createActionPropertyChangeListener): Likewise.
(configurePropertiesFromAction): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/DebugGraphics.java:
Re-formatted. Fixed some javadocs.
* javax/swing/JApplet.java
(rootPaneCheckingEnabled): Renamed from checking.
* javax/swing/JCheckBox.java
(BORDER_PAINTED_FLAT_CHANGED_PROPERTY): New statif field.
* javax/swing/JFrame.java:
Re-formatted a bit and reordered some methods.
(rootPaneCheckingEnabled): Renamed from checking.
(getPreferredSize): Simplified.
* javax/swing/JTextArea.java
(getColumnWidth): New method.
(getLineCount): Likewise.
(getLineStartOffset): Likewise.
(getLineEndOffset): Likewise.
(getLineOfOffset): Likewise.
(getRowHeight): Likewise.
(insert): Likewise.
(replaceRange): Likewise.
* javax/swing/JTextField.java
(scrollOffset): new field.
(getScrollOffset): New method.
(setScrollOffset): Likewise.
(getColumnWidth): Likewise.
* javax/swing/JTree.java
(ANCHOR_SELECTION_PATH_PROPERTY): New static field.
(CELL_EDITOR_PROPERTY): Likewise.
(CELL_RENDERER_PROPERTY): Likewise.
(EDITABLE_PROPERTY): Likewise.
(EXPANDS_SELECTED_PATHS_PROPERTY): Likewise.
(INVOKES_STOP_CELL_EDITING_PROPERTY): Likewise.
(LARGE_MODEL_PROPERTY): Likewise.
(LEAD_SELECTION_PATH_PROPERTY): Likewise.
(ROOT_VISIBLE_PROPERTY): Likewise.
(ROW_HEIGHT_PROPERTY): Likewise.
(SCROLLS_ON_EXPAND_PROPERTY): Likewise.
(SELECTION_MODEL_PROPERTY): Likewise.
(SHOWS_ROOT_HANDLES_PROPERTY): Likewise.
(TOGGLE_CLICK_COUNT_PROPERTY): Likewise.
(TREE_MODEL_PROPERTY): Likewise.
(VISIBLE_ROW_COUNT_PROPERTY): Likewise.
(cellEditor): New field.
(invokesStopCellEditing): Likewise.
(largeModel): Likewise.
(rowHeight): Likewise.
(scrollsOnExpand): Likewise.
(selectionModel): Likewise.
(toggleClickCount): Likewise.
(visibleRowCount): Likewise.
(setShowsRootHandles): Fixed typo in method name.
(getCellEditor): New method.
(setCellEditor): Likewise.
(getSelectionModel): Likewise.
(setSelectionModel): Likewise.
(getVisibleRowCount): Likewise.
(setVisibleRowCount): Likewise.
(isLargeModel): Likewise.
(setLargeModel): Likewise.
(getRowHeight): Likewise.
(setRowHeight): Likewise.
(getInvokesStopCellEditing): Likewise.
(setInvokesStopCellEditing): Likewise.
(getToggleClickCount): Likewise.
(setToggleClickCount): Likewise.
(getScrollsOnExpand): Likewise.
(setScrollsOnExpand): Likewise.
* javax/swing/table/DefaultTableColumnModel.java
(addColumnModelListener): Fixed javadoc.
(removeColumnModelListener): Implemented. Fixed javadoc.
(getColumnModelListeners): New method.
* javax/swing/table/JTableHeader.java
(columnModel): Made protected.
(draggedColumn): Likewise.
(draggedDistance): Likewise.
(reorderingAllowed): Likewise.
(resizingAllowed): Likewise.
(resizingColumn): Likewise.
(table): Likewise.
(updateTableInRealTime): Likewise.
(createDefaultColumnModel): Renamed from
createDefaultTableColumnModel.
(setDefaultRenderer): New method.
* javax/swing/table/TableColumn.java
(getPropertyChangeListeners): New method.
* javax/swing/text/DefaultHighlighter.java
(drawsLayeredHighlights): New field.
(getDrawsLayeredHighlights): New method.
(setDrawsLayeredHighlights): Likewise.
* javax/swing/text/DocumentFilter.java
(FilterBypass): New inner class.
(insertString): New method.
(remove): Likewise.
(replace): Likewise.
* javax/swing/text/JTextComponent.java
(dragEnabled): New field.
(getSelectedText): New method.
(getDragEnabled): Likewise.
(setDragEnabled): Likewise.
(replaceSelection): Reimplemented.
* javax/swing/text/NavigationFilter.java
(FilterBypass): New inner class.
(NavigationFilter): New method.
(moveDot): Likewise.
(setDot): Likewise.
* javax/swing/text/SimpleAttributeSet.java
(EMPTY): Made public final.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/SpinnerNumberModel.java
(getMinimum): New method.
(setMinimum): Likewise.
(getMaximum): Likewise.
(setMaximum): Likewise.
(getStepSize): Likewise.
(setStepSize): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JMenu.java
(getMenuListeners): New method.
(fireMenuSelected): Simplified.
* javax/swing/JRootPane.java
(NONE): New static field.
(FRAME): Likewise.
(PLAIN_DIALOG): Likewise.
(INFORMATION_DIALOG): Likewise.
(ERROR_DIALOG): Likewise.
(COLOR_CHOOSER_DIALOG): Likewise.
(FILE_CHOOSER_DIALOG): Likewise.
(QUESTION_DIALOG): Likewise.
(WARNING_DIALOG): Likewise.
(defaultButton): New field.
(getDefaultButton): New method.
(setDefaultButton): Likewise.
* javax/swing/JScrollPane.java
(getUI): New method.
(setUI): Likewise.
* javax/swing/JTable.java
(getUI): Javadoc added.
(setUI): New method.
* javax/swing/JViewport.java
(getUI): New method.
(setUI): Likewise.
* javax/swing/UIDefaults.java
(removePropertyChangeListener): Made public.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JApplet.java, javax/swing/JFrame.java:
Re-indented.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/AbstractButton.java:
Little re-formatting.
(changeEvent): Made protected.
(fireStateChanged): Removed argument.
(setHorizontalAlignment): Abort method when old value is equal too new
value.
(setHorizontalTextPosition): Likewise.
(setVerticalAlignment): Likewise.
(setVerticalTextPosition): Likewise.
(setBorderPainted): Likewise.
(setIcon): Likewise.
(setText): Likewise.
(setIconTextGap): Likewise.
(setMargin): Likewise.
(setPressedIcon): Likewise.
(setFocusPainted): Likewise.
(setDisabledSelectedIcon): Likewise.
(setRolloverIcon): Likewise.
(setRolloverSelectedIcon): Likewise.
(setSelectedIcon): Likewise.
(setContentAreaFilled): Likewise.
2004-11-30 Kim Ho <kho@redhat.com>
* javax/swing/plaf/basic/BasicArrowButton.java:
Jalopy. Reimplement.
* javax/swing/plaf/basic/BasicScrollBarUI.java:
Jalopy.
(arrowIcon, upIcon, downIcon, leftIcon,
rightIcon): Removed.
(createIncreaseButton): Use BasicArrowButton.
(createDecreaseButton): Ditto.
* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
(createRightOneTouchButton): Remove button border.
(createLeftOneTouchButton): Ditto.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JSpinner.java
(setModel): New method.
* javax/swing/SpringLayout.java
(Constraints): May not be final.
2004-11-30 Michael Koch <konqueror@gmx.de>
* gnu/java/awt/peer/gtk/GtkClipboard.java,
java/awt/datatransfer/Clipboard.java,
java/awt/datatransfer/ClipboardOwner.java:
Reformated to make it use our coding standard.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/SpinnerNumberModel.java
(SpinnerNumberModel): Implements java.io.Serializable.
(serialVersionUID): New field.
(SpinnerNumberModel): Added missing @throws tags to javadocs.
* javax/swing/UIManager.java
(get): New method.
(getBoolean): Likewise.
(getBorder): Likewise.
(getColor): Likewise.
(getDimension): Likewise.
(getFont): Likewise.
(getIcon): Likewise.
(getInsets): Likewise.
(getInt): Likewise.
(getString): Likewise.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JPasswordField.java:
Reformated. Implemented construtors.
* javax/swing/plaf/basic/BasicPasswordFieldUI.java
(create): New method.
* javax/swing/text/PlainView.java
(selectedColor): Made package-private to allow access from sub-classes
in same package too.
(unselectedColor): Likewise.
(font): Likewise.
(drawSelectedText): Make protected.
(drawUnselectedText): Likewise.
* javax/swing/text/PasswordView.java: New file.
* Makefile.am: Added javax/swing/text/PasswordView.java.
* Makefile.in: Regenerated.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkFramePeer.java (setMenuBar): Set menu
bar's width.
* gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (nativeSetHelpMenu):
Add FIXME comment.
(addHelpMenu): Elide call to nativeSetHelpMenu.
* java/awt/Menu.java (isTearOff): Rename to tearOff.
(menuSerializedDataVersion): Initialize to 1.
(separatorLabel): Mark transient.
(insert(MenuItem,int)): Implement.
* java/awt/MenuBar.java (setHelpMenu): Call getPeer to retrieve
peer.
(countMenus): Count help menu.
* java/awt/MenuComponent.java (nameExplicitlySet, newEventsOnly,
accessibleContext): Add fields.
* java/awt/MenuItem.java: Remove event mask FIXME.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
(gtkWidgetModifyFont): Only set font if label is non-NULL.
(setLabel): Don't treat "-" specially.
2004-11-30 Kim Ho <kho@redhat.com>
* javax/swing/colorchooser/DefaultHSBChooserPanel.java:
(stateChanged): Only update the image and the track if
the values are not being adjusted.
(updateChooser): Grab the new mouse point from the
spinner values. Update the image and track only if
the values are not being adjusted.
(getHSBValues): New method.
* javax/swing/colorchooser/DefaultRGBChooserPanel.java:
(SliderHandler::stateChanged): Changed internalChange
to updateChange. Set sliderChange.
(SpinnerHandler::stateChanged): Ditto. Set spinnerChange.
(spinnerChange): New variable.
(sliderChange): Ditto.
(updateChange): Renamed from internalChange.
(updateChooser): Do not update sliders if the sliders
were the original source of the change. Ditto for spinners.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
(mousePress): Don't scroll the JViewport if there will
be extra space at the end of the run. Change layout() to
revalidate().
(calculateSize): Use the component's width/height unless
it is smaller than the max tab width/height.
(calculateTabRects): Subtract the tab run overlay.
(rotateTabRuns): Don't rotate if there's only one run.
(layoutContainer): Reuse the viewport point.
(createLayoutManager): Set the viewport to use no layout.
(paintTabArea): Don't paint the tabs that are not visible
to the JViewport.
(paintContentBorderTopEdge): Check for scroll tab layout before
looking for gap.
(paintContentBorderLeftEdge): Ditto.
(paintContentBorderBottomEdge): Ditto.
(paintContentBorderRightEdge): Ditto.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkButtonPeer.java (gtkWidgetSetFont):
Rename ...
(gtkWidgetModifyFont): New method.
* gnu/java/awt/peer/gtk/GtkFramePeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
(setMenuBarWidth): New method.
(setBounds): Set the menu bar width.
(postConfigureEvent): Set the menu bar width if the window's
width has changed.
* gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (GtkMenuBarPeer):
Don't call create.
(setFont): New method.
* gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java (create): New
method.
(setFont): Likewise.
(GtkMenuComponentPeer): Call create and setFont.
* gnu/java/awt/peer/gtk/GtkMenuItemPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
(connectSignals): Make package private.
(gtkWidgetModifyFont): New method.
(create): Likewise.
(GtkMenuItemPeer): Don't call create.
(setFont): New method.
* java/awt/CheckboxMenuItem.java (addNotify): Fix peer == null
condition.
* java/awt/Container.java (validateTree): Fix comment typos.
* java/awt/MenuComponent.java (getFont): Return parent's font if
our font is null.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c
(create): Remove call to deprecated
gtk_check_menu_item_set_show_toggle function.
2004-11-30 Hans Boehm <Hans.Boehm@hp.com>
* java/lang/natObject.cc (LOCK_LOG, LOG): Add debug tracing.
(Almost everywhere): add LOG calls, fix, add comments.
(_Jv_MonitorEnter): Replace masking of LOCKED bit with assertion.
Add explicit check for LOCKED bit in slow case (PR 16662).
(_Jv_MonitorExit): Add casts in debug-only code.
Always release LOCKED bit before throwing exception.
(_Jv_ObjectCheckMonitor): Lock may be held if lightweight lock
isn't. Handle easy cases without lock acquisition.
(Object::wait): Use NotifyAll for lock inflation.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkFramePeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
(gtkFixedMove): Remove method.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/Area.java: Implemented.
2004-11-30 Mark Wielaard <mark@klomp.org>
* java/awt/geom/Arc2D.java (ArcIterator): Make package private.
2004-11-30 Sven de Marothy <sven@physto.se>
* java/awt/geom/Arc2D.java
Reformatted.
(setArc): Correct documentation to say 'upper left corner'.
(setArcByTangent,contains,intersects): Implemented.
(containsAngle): Corrected to handle negative extents.
(ArcIterator): Set to private.
(ArcIterator): Corrected for CHORD-type arcs, negative extents.
* java/awt/geom/Ellipse2D.java
Documented.
(contains,intersects): Implemented.
* java/awt/geom/Line2D.java
(linesIntersect): Correct handling of special cases.
2004-11-30 Mark Wielaard <mark@klomp.org>
* gnu/java/awt/peer/gtk/GdkGraphics.java (setColor): Use
Color.BLACK if c == null, don't create new Color object each time.
* gnu/java/awt/peer/gtk/GdkGraphics2D.java (comp): New private
field.
(setColor): Use Color.BLACK when argument null.
(setComposite): Set this.comp field.
(getComposite): Return this.comp, or AlphaComposite.SrcOver when null.
(DrawState.comp): New private field.
(DrawState.save): Save Composite.
(DrawState.restore): Restore comp field.
* java/awt/FontMetrics.java (gRC): New static final private field.
(getLineMetrics(String, Graphics)): New method.
(getLineMetrics(String, int, int, Graphics)): Likewise.
(getLineMetrics(char[], int, int, Graphics)): Likewise.
(getLineMetrics(CharacterIterator, int, int, Graphics)): Likewise.
* javax/swing/JMenu.java (JMenu(String, boolean)): Ignore tearoff
argument. PR SWING/17294.
* javax/swing/plaf/basic/BasicGraphicsUtils.java (): Always use
the fall-back code since none of the TextArea methods are really
implemented now. PR SWING/17296.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c
(GdkGlyphVector_setChars): Replace assert() with if block when
pango_itemize() returns null. PR AWT/17295.
(GdkGlyphVector_allInkExtents): Likewise when vec->glyphitems is null.
2004-11-30 Thomas Fitzsimmons <fitzsim@redhat.com>
* Makefile.am (gtk_c_source_files): Add
gnu_java_awt_peer_gtk_GtkFramePeer.c.
* Makefile.in: Regenerate.
* gnu/java/awt/peer/gtk/GdkGraphics.java (getClipBounds): Remove
comment.
* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
(create): Pack GtkButton in GtkEventBox.
(connectJObject): Remove.
(focus_in_cb): New function.
(focus_out_cb): Likewise.
(connectSignals): Connect focus-in-event and focus-out-event
signals.
(gtkSetFont): Rename to ...
(gtkWidgetModifyFont): New method.
(gtkWidgetRequestFocus): New method.
* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
(gtkSetFont): Rename to ...
(gtkWidgetModifyFont): New method.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(isInRepaint): New field.
(gtkSetFont): Remove method.
(addExposeFilter): Likewise.
(removeExposeFilter): Likewise.
(gtkWidgetQueueDrawArea): Rename to ...
(gtkWidgetRepaintArea): New method.
(beginNativeRepaint): New method.
(endNativeRepaint): New method.
(setComponentBounds): Move implementation here from
GtkComponentPeer.
(paint): Remove implementation.
(repaint): Wrap call to gtkWidgetRepaintArea with calls to
beginNativeRepaint and endNativeRepaint.
(setBounds): Use menu bar height in bounds calculation.
(postExposeEvent): Only post paint event if we're not doing a
native repaint.
(gtkWidgetSetParent): Replace gtk_layout_put with gtk_fixed_put.
(setNativeBounds): Replace gtk_layout_move with gtk_fixed_move.
(find_gtk_layout): Remove function.
(filter_expose_event_handler): Likewise.
* gnu/java/awt/peer/gtk/GtkDialogPeer.java (postExposeEvent):
Likewise.
* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
(setComponentBounds): Call GtkComponentPeer's
setComponentBounds.
* gnu/java/awt/peer/gtk/GtkFramePeer.java (getMenuBarHeight):
New method.
(moveLayout): Rename to ...
(gtkFixedMove): New method.
(gtkLayoutSetVisible): Rename to ...
(gtkFixedSetVisible): New method.
(setMenuBar): Rearrange, to make the three separate cases
clearer.
(postExposeEvent): Only post paint event if we're not doing a
native repaint.
* gnu/java/awt/peer/gtk/GtkGenericPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkGenericPeer.c
(gtkWidgetModifyFont): New method.
* gnu/java/awt/peer/gtk/GtkImagePainter.java
(GtkImagePainter(GtkImage,GdkGraphics,int,int,int,int,Color)):
Call run directly, rather than spawning a new thread.
(GtkImagePainter(GtkImage,GdkGraphics,int,int,int,int,int,int,int,int,Color)):
Likewise.
* gnu/java/awt/peer/gtk/GtkLabelPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c (gtkSetFont):
Rename to ...
(gtkWidgetModifyFont): New method.
(create): Rename ebox to eventbox.
* gnu/java/awt/peer/gtk/GtkListPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c (gtkSetFont):
Rename to ...
(gtkWidgetModifyFont): New method.
* gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
(GtkMenuComponentPeer): Set the default font.
* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
(gtkSetFont): Rename to ...
(gtkWidgetModifyFont): New method.
* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c: Likewise.
* java/awt/Component.java (locale): Initialize to default
locale.
* java/awt/Container.java (invalidateTree): Make
package-private.
(paint): Paint self first.
(setMenuBar): Call invalidateTree.
* java/awt/Panel.java (dispatchEventImpl): Remove method.
* java/awt/Window.java (show): Call no-parameter variant of
requestFocusInWindow.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (initState):
Remove special case for window widget.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(grab_current_drawable): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c
(create): Replace GtkLayout with GtkFixed.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
(pre_event_handler): Remove special cases for GDK_EXPOSE events.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c: New file.
Move all GtkFramePeer native method implementations here from
gnu_java_awt_peer_gtk_GtkWindowPeer.c.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c (create):
Replace GtkLayout with GtkFixed.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(find_layout): Remove function.
(create): Replace GtkLayout with GtkFixed.
(connectSignals): Remove find_layout call.
(toBack): Replace XFlush with gdk_flush.
(toFront): Replace XFlush with gdk_flush.
Move GtkFramePeer native method implementations to
gnu_java_awt_peer_gtk_GtkFramePeer.c.
* jni/gtk-peer/gtkpeer.h: Remove declaration of find_gtk_layout.
2004-11-30 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextArea.java
(lineWrap): Renamed from "wrapping".
(wrapStyleWord): NEw field.
(getLineWrap): Re-edited javadoc comment.
(setLineWrap): Likewise.
(getWrapStyleWord): New method.
(setWrapStyleWord): Likewise.
From-SVN: r91544
Diffstat (limited to 'libjava/java/awt/image')
33 files changed, 4057 insertions, 202 deletions
diff --git a/libjava/java/awt/image/AffineTransformOp.java b/libjava/java/awt/image/AffineTransformOp.java index 6219635..1326a61 100644 --- a/libjava/java/awt/image/AffineTransformOp.java +++ b/libjava/java/awt/image/AffineTransformOp.java @@ -1,6 +1,6 @@ /* AffineTransformOp.java -- This class performs affine - * transformation between two images or rasters in 2 - * dimensions. Copyright (C) 2004 Free Software Foundation + transformation between two images or rasters in 2 dimensions. + Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. @@ -38,30 +38,39 @@ exception statement from your version. */ package java.awt.image; -import java.awt.*; -import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.geom.*; - +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; /** * This class performs affine transformation between two images or * rasters in 2 dimensions. * - * @author Olga Rodimina <rodimina@redhat.com> + * @author Olga Rodimina (rodimina@redhat.com) */ - public class AffineTransformOp implements BufferedImageOp, RasterOp { - public static final int TYPE_BILINEAR = 0; public static final int TYPE_NEAREST_NEIGHBOR = 1; + + public static final int TYPE_BILINEAR = 2; + + /** + * @since 1.5.0 + */ + public static final int TYPE_BICUBIC = 3; private AffineTransform transform; private RenderingHints hints; /** * Construct AffineTransformOp with the given xform and interpolationType. - * Interpolation type can be either TYPE_BILINEAR or TYPE_NEAREST_NEIGHBOR. + * Interpolation type can be TYPE_BILINEAR, TYPE_BICUBIC or + * TYPE_NEAREST_NEIGHBOR. * * @param xform AffineTransform that will applied to the source image * @param interpolationType type of interpolation used @@ -69,15 +78,23 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp public AffineTransformOp (AffineTransform xform, int interpolationType) { this.transform = xform; + if (xform.getDeterminant() == 0) + throw new ImagingOpException(null); - if (interpolationType == 0) + switch (interpolationType) + { + case TYPE_BILINEAR: hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - - else + break; + case TYPE_BICUBIC: + hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + break; + default: hints = new RenderingHints (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); - + } } /** @@ -90,6 +107,8 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp { this.transform = xform; this.hints = hints; + if (xform.getDeterminant() == 0) + throw new ImagingOpException(null); } /** @@ -149,7 +168,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp * @param dst destination image * @return transformed source image */ - public BufferedImage filter (BufferedImage src, BufferedImage dst) + public final BufferedImage filter (BufferedImage src, BufferedImage dst) { if (dst == src) @@ -180,9 +199,99 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp * @param dst destination raster * @return transformed raster */ - public WritableRaster filter (Raster src, WritableRaster dst) + public final WritableRaster filter (Raster src, WritableRaster dst) { - throw new UnsupportedOperationException ("not implemented yet"); + if (dst == src) + throw new IllegalArgumentException("src image cannot be the same as" + + " the dst image"); + + if (dst == null) + dst = createCompatibleDestRaster(src); + + if (src.getNumBands() != dst.getNumBands()) + throw new IllegalArgumentException("src and dst must have same number" + + " of bands"); + + double[] dpts = new double[dst.getWidth() * 2]; + double[] pts = new double[dst.getWidth() * 2]; + for (int x = 0; x < dst.getWidth(); x++) + { + dpts[2 * x] = x + dst.getMinX(); + dpts[2 * x + 1] = x; + } + Rectangle srcbounds = src.getBounds(); + if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)) + { + for (int y = dst.getMinY(); y < dst.getMinY() + dst.getHeight(); y++) + { + try { + transform.inverseTransform(dpts, 0, pts, 0, dst.getWidth() * 2); + } catch (NoninvertibleTransformException e) { + // Can't happen since the constructor traps this + e.printStackTrace(); + } + + for (int x = 0; x < dst.getWidth(); x++) + { + if (!srcbounds.contains(pts[2 * x], pts[2 * x + 1])) + continue; + dst.setDataElements(x + dst.getMinX(), y, + src.getDataElements((int)pts[2 * x], + (int)pts[2 * x + 1], + null)); + } + } + } + else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR)) + { + double[] tmp = new double[4 * src.getNumBands()]; + for (int y = dst.getMinY(); y < dst.getMinY() + dst.getHeight(); y++) + { + try { + transform.inverseTransform(dpts, 0, pts, 0, dst.getWidth() * 2); + } catch (NoninvertibleTransformException e) { + // Can't happen since the constructor traps this + e.printStackTrace(); + } + + for (int x = 0; x < dst.getWidth(); x++) + { + if (!srcbounds.contains(pts[2 * x], pts[2 * x + 1])) + continue; + int xx = (int)pts[2 * x]; + int yy = (int)pts[2 * x + 1]; + double dx = (pts[2 * x] - xx); + double dy = (pts[2 * x + 1] - yy); + + // TODO write this more intelligently + if (xx == src.getMinX() + src.getWidth() - 1 || + yy == src.getMinY() + src.getHeight() - 1) + { + // bottom or right edge + Arrays.fill(tmp, 0); + src.getPixel(xx, yy, tmp); + } + else + { + // Normal case + src.getPixels(xx, yy, 2, 2, tmp); + for (int b = 0; b < src.getNumBands(); b++) + tmp[b] = dx * dy * tmp[b] + + (1 - dx) * dy * tmp[b + src.getNumBands()] + + dx * (1 - dy) * tmp[b + 2 * src.getNumBands()] + + (1 - dx) * (1 - dy) * tmp[b + 3 * src.getNumBands()]; + } + dst.setPixel(x, y, tmp); + } + } + } + else + { + // Bicubic + throw new UnsupportedOperationException("not implemented yet"); + } + + return dst; } /** @@ -192,7 +301,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp * @param src image to be transformed * @return bounds of the transformed image. */ - public Rectangle2D getBounds2D (BufferedImage src) + public final Rectangle2D getBounds2D (BufferedImage src) { return getBounds2D (src.getRaster()); } @@ -203,7 +312,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp * @param src raster to be transformed * @return bounds of the transformed raster. */ - public Rectangle2D getBounds2D (Raster src) + public final Rectangle2D getBounds2D (Raster src) { // determine new size for the transformed raster. // Need to calculate transformed coordinates of the lower right @@ -222,7 +331,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp * * @return interpolation type */ - public int getInterpolationType () + public final int getInterpolationType () { if(hints.containsValue (RenderingHints.VALUE_INTERPOLATION_BILINEAR)) return TYPE_BILINEAR; @@ -243,21 +352,23 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp return transform.transform (srcPt, dstPt); } - /** Returns rendering hints that are used during transformation. + /** + * Returns rendering hints that are used during transformation. * * @return rendering hints */ - public RenderingHints getRenderingHints () + public final RenderingHints getRenderingHints () { return hints; } - /** Returns transform used in transformation between source and destination + /** + * Returns transform used in transformation between source and destination * image. * * @return transform */ - public AffineTransform getTransform () + public final AffineTransform getTransform () { return transform; } diff --git a/libjava/java/awt/image/BandCombineOp.java b/libjava/java/awt/image/BandCombineOp.java new file mode 100644 index 0000000..48c61c5 --- /dev/null +++ b/libjava/java/awt/image/BandCombineOp.java @@ -0,0 +1,168 @@ +/* Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.awt.image; + +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +/** + * Filter Raster pixels by applying a matrix. + * + * BandCombineOp applies a matrix to each pixel to produce new pixel values. + * The width of the matrix must be the same or one more than the number of + * bands in the source Raster. If one more, the pixels in the source are + * assumed to contain an implicit 1.0 at the end. + * + * The rows of the matrix are multiplied by the pixel to produce the values + * for the destination. Therefore the destination Raster must contain the + * same number of bands as the number of rows in the filter matrix. + * + * @author Jerry Quinn <jlquinn@optonline.net> + */ +public class BandCombineOp implements RasterOp +{ + private RenderingHints hints; + private float[][] matrix; + + /** + * Construct a BandCombineOp. + * + * @param matrix The matrix to filter pixels with. + * @param hints Rendering hints to apply. Ignored. + */ + public BandCombineOp(float[][] matrix, RenderingHints hints) + { + this.matrix = matrix; + this.hints = hints; + } + + /** + * Filter Raster pixels through a matrix. + * + * Applies the Op matrix to source pixes to produce dest pixels. Each row + * of the matrix is multiplied by the src pixel components to produce the + * dest pixel. If matrix is one more than the number of bands in the src, + * the last element is implicitly multiplied by 1, i.e. added to the sum + * for that dest component. + * + * If dest is null, a suitable Raster is created. This implementation uses + * createCompatibleDestRaster. + * + * @param src The source Raster. + * @param dest The destination Raster, or null. + * @returns The destination Raster or an allocated Raster. + * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, + *java.awt.image.WritableRaster) + */ + public WritableRaster filter(Raster src, WritableRaster dest) { + if (dest == null) + dest = createCompatibleDestRaster(src); + + // Filter the pixels + float[] spix = new float[matrix[0].length]; + float[] dpix = new float[matrix.length]; + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + { + // In case matrix rows have implicit translation + spix[spix.length - 1] = 1.0f; + src.getPixel(x, y, spix); + for (int i = 0; i < matrix.length; i++) + { + dpix[i] = 0; + for (int j = 0; j < matrix[0].length; j++) + dpix[i] += spix[j] * matrix[i][j]; + } + dest.setPixel(x, y, dpix); + } + + return dest; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster) + */ + public Rectangle2D getBounds2D(Raster src) + { + return src.getBounds(); + } + + /** + * Creates a new WritableRaster that can be used as the destination for this + * Op. This implementation creates a Banded Raster with data type FLOAT. + * @see + *java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) + */ + public WritableRaster createCompatibleDestRaster(Raster src) + { + return Raster.createBandedRaster(DataBuffer.TYPE_FLOAT, src.getWidth(), + src.getHeight(), matrix.length, + new Point(src.getMinX(), src.getMinY())); + } + + /** Return corresponding destination point for source point. + * + * LookupOp will return the value of src unchanged. + * @param src The source point. + * @param dst The destination point. + * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, + *java.awt.geom.Point2D) + */ + public Point2D getPoint2D(Point2D src, Point2D dst) + { + if (dst == null) return (Point2D)src.clone(); + dst.setLocation(src); + return dst; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getRenderingHints() + */ + public RenderingHints getRenderingHints() + { + return hints; + } + + /** Return the matrix for this Op. */ + public float[][] getMatrix() + { + return matrix; + } + +} diff --git a/libjava/java/awt/image/BandedSampleModel.java b/libjava/java/awt/image/BandedSampleModel.java new file mode 100644 index 0000000..93252d9 --- /dev/null +++ b/libjava/java/awt/image/BandedSampleModel.java @@ -0,0 +1,537 @@ +/* Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.awt.image; + +/** + * MultiPixelPackedSampleModel provides a single band model that supports + * multiple pixels in a single unit. Pixels have 2^n bits and 2^k pixels fit + * per data element. + * + * @author Jerry Quinn <jlquinn@optonline.net> + */ +public final class BandedSampleModel extends ComponentSampleModel +{ + private int[] bitMasks; + private int[] bitOffsets; + private int[] sampleSize; + private int dataBitOffset; + private int elemBits; + private int numberOfBits; + private int numElems; + + public BandedSampleModel(int dataType, int w, int h, int numBands) + { + super(dataType, w, h, 1, w, new int[numBands]); + } + + public BandedSampleModel(int dataType, int w, int h, int scanlineStride, + int[] bankIndices, int[] bandOffsets) + { + super(dataType, w, h, 1, scanlineStride, bankIndices, bandOffsets); + } + + public SampleModel createCompatibleSampleModel(int w, int h) + { + // NOTE: blackdown 1.4.1 sets all offsets to 0. Sun's 1.4.2 docs + // disagree. + + // Compress offsets so minimum is 0, others w*scanlineStride + int[] newoffsets = new int[bandOffsets.length]; + int[] order = new int[bandOffsets.length]; + for (int i=0; i < bandOffsets.length; i++) + order[i] = i; + // FIXME: This is N^2, but not a big issue, unless there's a lot of + // bands... + for (int i=0; i < bandOffsets.length; i++) + for (int j=i+1; j < bandOffsets.length; i++) + if (bankIndices[order[i]] > bankIndices[order[j]] + || (bankIndices[order[i]] == bankIndices[order[j]] + && bandOffsets[order[i]] > bandOffsets[order[j]])) + { + int t = order[i]; order[i] = order[j]; order[j] = t; + } + int bank = 0; + int offset = 0; + for (int i=0; i < bandOffsets.length; i++) + { + if (bankIndices[order[i]] != bank) + { + bank = bankIndices[order[i]]; + offset = 0; + } + newoffsets[order[i]] = offset; + offset += w * scanlineStride; + } + + return new BandedSampleModel(dataType, w, h, scanlineStride, bankIndices, newoffsets); + } + + + public SampleModel createSubsetSampleModel(int[] bands) + { + int[] newoff = new int[bands.length]; + int[] newbanks = new int[bands.length]; + for (int i=0; i < bands.length; i++) + { + int b = bands[i]; + newoff[i] = bandOffsets[b]; + newbanks[i] = bankIndices[b]; + } + + if (bands.length > bankIndices.length) + throw new + RasterFormatException("BandedSampleModel createSubsetSampleModel too" + +" many bands"); + + return new BandedSampleModel(dataType, width, height, scanlineStride, + newbanks, newoff); + } + + /** + * Extract all samples of one pixel and return in an array of transfer type. + * + * Extracts the pixel at x, y from data and stores samples into the array + * obj. If obj is null, a new array of getTransferType() is created. + * + * @param x The x-coordinate of the pixel rectangle to store in <code>obj</code>. + * @param y The y-coordinate of the pixel rectangle to store in <code>obj</code>. + * @param obj The primitive array to store the pixels into or null to force creation. + * @param data The DataBuffer that is the source of the pixel data. + * @return The primitive array containing the pixel data. + * @see java.awt.image.SampleModel#getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer) + */ + public Object getDataElements(int x, int y, Object obj, + DataBuffer data) + { + int pixel = getSample(x, y, 0, data); + switch (getTransferType()) + { + case DataBuffer.TYPE_BYTE: + { + byte[] b = (byte[])obj; + if (b == null) b = new byte[numBands]; + for (int i=0; i < numBands; i++) + b[i] = (byte)getSample(x, y, i, data); + return b; + } + case DataBuffer.TYPE_SHORT: + case DataBuffer.TYPE_USHORT: + { + short[] b = (short[])obj; + if (b == null) b = new short[numBands]; + for (int i=0; i < numBands; i++) + b[i] = (short)getSample(x, y, i, data); + return b; + } + case DataBuffer.TYPE_INT: + { + int[] b = (int[])obj; + if (b == null) b = new int[numBands]; + for (int i=0; i < numBands; i++) + b[i] = getSample(x, y, i, data); + return b; + } + case DataBuffer.TYPE_FLOAT: + { + float[] b = (float[])obj; + if (b == null) b = new float[numBands]; + for (int i=0; i < numBands; i++) + b[i] = getSampleFloat(x, y, i, data); + return b; + } + case DataBuffer.TYPE_DOUBLE: + { + double[] b = (double[])obj; + if (b == null) b = new double[numBands]; + for (int i=0; i < numBands; i++) + b[i] = getSample(x, y, i, data); + return b; + } + + default: + // Seems like the only sensible thing to do. + throw new ClassCastException(); + } + } + + public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) + { + if (iArray == null) iArray = new int[numBands]; + for (int i=0; i < numBands; i++) + iArray[i] = getSample(x, y, 0, data); + + return iArray; + } + + /** + * Copy pixels from a region into an array. + * + * Copies the samples of the pixels in the rectangle starting at x, y that + * is w pixels wide and h scanlines high. When there is more than one band, + * the samples stored in order before the next pixel. This ordering isn't + * well specified in Sun's docs as of 1.4.2. + * + * If iArray is null, a new array is allocated, filled, and returned. + * + * @param x The x-coordinate of the pixel rectangle to store in + * <code>iArray</code>. + * @param y The y-coordinate of the pixel rectangle to store in + * <code>iArray</code>. + * @param w The width in pixels of the rectangle. + * @param h The height in pixels of the rectangle. + * @param iArray The int array to store the pixels into or null to force + * creation. + * @param data The DataBuffer that is the source of the pixel data. + * @return The primitive array containing the pixel data. + */ + public int[] getPixels(int x, int y, int w, int h, int[] iArray, + DataBuffer data) + { + if (iArray == null) iArray = new int[w*h*numBands]; + int outOffset = 0; + for (y=0; y<h; y++) + { + for (x=0; x<w;) + { + for (int b=0; b < numBands; b++) + { + int offset = bandOffsets[b] + y * scanlineStride + x; + iArray[outOffset++] = + data.getElem(bankIndices[b], offset); + } + } + } + return iArray; + } + + public int getSample(int x, int y, int b, DataBuffer data) + { + int offset = bandOffsets[b] + y * scanlineStride + x; + return data.getElem(bankIndices[b], offset); + } + + public float getSampleFloat(int x, int y, int b, DataBuffer data) + { + int offset = bandOffsets[b] + y * scanlineStride + x; + return data.getElemFloat(bankIndices[b], offset); + } + + public double getSampleDouble(int x, int y, int b, DataBuffer data) + { + int offset = bandOffsets[b] + y * scanlineStride + x; + return data.getElemDouble(bankIndices[b], offset); + } + + /** + * Copy one band's samples from a region into an array. + * + * Copies from one band the samples of the pixels in the rectangle starting + * at x, y that is w pixels wide and h scanlines high. + * + * If iArray is null, a new array is allocated, filled, and returned. + * + * @param x The x-coordinate of the pixel rectangle to store in + * <code>iArray</code>. + * @param y The y-coordinate of the pixel rectangle to store in + * <code>iArray</code>. + * @param w The width in pixels of the rectangle. + * @param h The height in pixels of the rectangle. + * @param b The band to retrieve. + * @param iArray The int array to store the pixels into or null to force + * creation. + * @param data The DataBuffer that is the source of the pixel data. + * @return The primitive array containing the pixel data. + */ + public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, + DataBuffer data) + { + if (iArray == null) iArray = new int[w*h]; + int outOffset = 0; + for (y=0; y<h; y++) + { + for (x=0; x<w;) + { + int offset = bandOffsets[b] + y * scanlineStride + x; + iArray[outOffset++] = + data.getElem(bankIndices[b], offset); + } + } + return iArray; + } + + + /** + * Set the pixel at x, y to the value in the first element of the primitive + * array obj. + * + * @param x The x-coordinate of the data elements in <code>obj</code>. + * @param y The y-coordinate of the data elements in <code>obj</code>. + * @param obj The primitive array containing the data elements to set. + * @param data The DataBuffer to store the data elements into. + * @see java.awt.image.SampleModel#setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer) + */ + public void setDataElements(int x, int y, Object obj, DataBuffer data) + { + int transferType = getTransferType(); + if (getTransferType() != data.getDataType()) + { + throw new IllegalArgumentException("transfer type ("+ + getTransferType()+"), "+ + "does not match data "+ + "buffer type (" + + data.getDataType() + + ")."); + } + + int offset = y * scanlineStride + x; + + try + { + switch (transferType) + { + case DataBuffer.TYPE_BYTE: + { + DataBufferByte out = (DataBufferByte) data; + byte[] in = (byte[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + case DataBuffer.TYPE_SHORT: + { + DataBufferShort out = (DataBufferShort) data; + short[] in = (short[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + case DataBuffer.TYPE_USHORT: + { + DataBufferUShort out = (DataBufferUShort) data; + short[] in = (short[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + case DataBuffer.TYPE_INT: + { + DataBufferInt out = (DataBufferInt) data; + int[] in = (int[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + case DataBuffer.TYPE_FLOAT: + { + DataBufferFloat out = (DataBufferFloat) data; + float[] in = (float[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + case DataBuffer.TYPE_DOUBLE: + { + DataBufferDouble out = (DataBufferDouble) data; + double[] in = (double[]) obj; + for (int i=0; i < numBands; i++) + out.getData(bankIndices[i])[offset + bandOffsets[i]] = in[0]; + return; + } + default: + throw new ClassCastException("Unsupported data type"); + } + } + catch (ArrayIndexOutOfBoundsException aioobe) + { + String msg = "While writing data elements" + + ", x="+x+", y="+y+ + ", width="+width+", height="+height+ + ", scanlineStride="+scanlineStride+ + ", offset="+offset+ + ", data.getSize()="+data.getSize()+ + ", data.getOffset()="+data.getOffset()+ + ": " + + aioobe; + throw new ArrayIndexOutOfBoundsException(msg); + } + } + + public void setPixel(int x, int y, int[] iArray, DataBuffer data) + { + for (int b=0; b < numBands; b++) + data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, + iArray[b]); + } + + public void setPixels(int x, int y, int w, int h, int[] iArray, + DataBuffer data) + { + int inOffset = 0; + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = y * scanlineStride + (x + ww); + for (int b=0; b < numBands; b++) + data.setElem(bankIndices[b], bandOffsets[b] + offset, + iArray[inOffset++]); + } + y++; + } + } + + public void setSample(int x, int y, int b, int s, DataBuffer data) + { + data.setElem(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); + } + + public void setSample(int x, int y, int b, float s, DataBuffer data) + { + data.setElemFloat(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); + } + + public void setSample(int x, int y, int b, double s, DataBuffer data) + { + data.setElemDouble(bankIndices[b], bandOffsets[b] + y * scanlineStride + x, s); + } + + public void setSamples(int x, int y, int w, int h, int b, int[] iArray, + DataBuffer data) + { + int inOffset = 0; + + switch (getTransferType()) + { + case DataBuffer.TYPE_BYTE: + { + DataBufferByte out = (DataBufferByte) data; + byte[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (byte)iArray[inOffset++]; + } + y++; + } + return; + } + case DataBuffer.TYPE_SHORT: + { + DataBufferShort out = (DataBufferShort) data; + short[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (short)iArray[inOffset++]; + } + y++; + } + return; + } + case DataBuffer.TYPE_USHORT: + { + DataBufferShort out = (DataBufferShort) data; + short[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = (short)iArray[inOffset++]; + } + y++; + } + return; + } + case DataBuffer.TYPE_INT: + { + DataBufferInt out = (DataBufferInt) data; + int[] bank = out.getData(bankIndices[b]); + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + bank[offset] = iArray[inOffset++]; + } + y++; + } + return; + } + case DataBuffer.TYPE_FLOAT: + case DataBuffer.TYPE_DOUBLE: + break; + default: + throw new ClassCastException("Unsupported data type"); + } + + // Default implementation probably slower for float and double + for (int hh = 0; hh < h; hh++) + { + for (int ww = 0; ww < w; ww++) + { + int offset = bandOffsets[b] + y * scanlineStride + (x + ww); + data.setElem(bankIndices[b], offset, iArray[inOffset++]); + } + y++; + } + } + + /** + * Creates a String with some information about this SampleModel. + * @return A String describing this SampleModel. + * @see java.lang.Object#toString() + */ + public String toString() + { + StringBuffer result = new StringBuffer(); + result.append(getClass().getName()); + result.append("["); + result.append("scanlineStride=").append(scanlineStride); + for(int i=0; i < bitMasks.length; i+=1) + { + result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i])); + } + + result.append("]"); + return result.toString(); + } +} diff --git a/libjava/java/awt/image/BufferedImage.java b/libjava/java/awt/image/BufferedImage.java index b18779a..723eeeb 100644 --- a/libjava/java/awt/image/BufferedImage.java +++ b/libjava/java/awt/image/BufferedImage.java @@ -1,4 +1,5 @@ -/* Copyright (C) 2000, 2002, 2003 Free Software Foundation +/* BufferedImage.java -- + Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -37,6 +38,8 @@ exception statement from your version. */ package java.awt.image; +import gnu.java.awt.ComponentDataBlitOp; + import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; @@ -45,11 +48,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Transparency; import java.awt.color.ColorSpace; -import java.util.Hashtable; -import java.util.Vector; import java.util.HashSet; +import java.util.Hashtable; import java.util.Iterator; -import gnu.java.awt.ComponentDataBlitOp; +import java.util.Vector; /** * A buffered image always starts at coordinates (0, 0). @@ -59,7 +61,7 @@ import gnu.java.awt.ComponentDataBlitOp; * height of the image. This tile is always considered to be checked * out. * - * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> + * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class BufferedImage extends Image implements WritableRenderedImage @@ -79,20 +81,20 @@ public class BufferedImage extends Image TYPE_BYTE_BINARY = 12, TYPE_BYTE_INDEXED = 13; - final static int[] bits3 = { 8, 8, 8 }; - final static int[] bits4 = { 8, 8, 8 }; - final static int[] bits1byte = { 8 }; - final static int[] bits1ushort = { 16 }; + static final int[] bits3 = { 8, 8, 8 }; + static final int[] bits4 = { 8, 8, 8 }; + static final int[] bits1byte = { 8 }; + static final int[] bits1ushort = { 16 }; - final static int[] masks_int = { 0x00ff0000, + static final int[] masks_int = { 0x00ff0000, 0x0000ff00, 0x000000ff, DataBuffer.TYPE_INT }; - final static int[] masks_565 = { 0xf800, + static final int[] masks_565 = { 0xf800, 0x07e0, 0x001f, DataBuffer.TYPE_USHORT}; - final static int[] masks_555 = { 0x7c00, + static final int[] masks_555 = { 0x7c00, 0x03e0, 0x001f, DataBuffer.TYPE_USHORT}; diff --git a/libjava/java/awt/image/BufferedImageFilter.java b/libjava/java/awt/image/BufferedImageFilter.java new file mode 100644 index 0000000..8fa7d47 --- /dev/null +++ b/libjava/java/awt/image/BufferedImageFilter.java @@ -0,0 +1,110 @@ +/* Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.awt.image; + +import java.awt.Point; + +/** + * The BufferedImageFilter class wraps BufferedImageOp objects in a Filter. + * + * When pixels are pushed through the filter, we create a BufferedImage, + * apply the BufferedImageOp, and pass the filtered pixels to the base class. + * + * @author jlquinn@optonline.net + */ +public class BufferedImageFilter extends ImageFilter implements Cloneable +{ + private BufferedImageOp op; + + /** + * + */ + public BufferedImageFilter(BufferedImageOp op) + { + super(); + if (op == null) + throw new NullPointerException("BufferedImageFilter null" + + " op in constructor"); + this.op = op; + } + + /** + * @return Returns the contained BufferedImageOp. + */ + public BufferedImageOp getBufferedImageOp() + { + return op; + } + + // FIXME: Definitely not sure this is the right thing. I'm not sure how to + // create a compatible sample model that incorporates scansize != w. I + // asume off is handled by the db itself. + public void setPixels(int x, int y, int w, int h, ColorModel model, + byte[] pixels, int off, int scansize) + { + // Create an input BufferedImage + DataBufferByte db = new DataBufferByte(pixels, scansize * h + off, off); + SampleModel sm = model.createCompatibleSampleModel(scansize, h); + WritableRaster wr = new WritableRaster(sm, db, new Point(0, 0)); + BufferedImage in = + new BufferedImage(model, wr, model.isAlphaPremultiplied(), null); + BufferedImage out = op.createCompatibleDestImage(in, model); + op.filter(in, out); + DataBuffer dbout = out.getRaster().getDataBuffer(); + super.setPixels(0, 0, w, h, model, ((DataBufferByte)dbout).getData(), 0, + scansize); + } + + // FIXME: Definitely not sure this is the right thing. I'm not sure how + // to create a compatible sample model that incorporates + // scansize != w. I asume off is handled by the db itself. + public void setPixels(int x, int y, int w, int h, ColorModel model, + int[] pixels, int off, int scansize) + { + // Create an input BufferedImage + DataBufferInt db = new DataBufferInt(pixels, scansize * h + off, off); + SampleModel sm = model.createCompatibleSampleModel(scansize, h); + WritableRaster wr = new WritableRaster(sm, db, new Point(0, 0)); + BufferedImage in = + new BufferedImage(model, wr, model.isAlphaPremultiplied(), null); + BufferedImage out = op.createCompatibleDestImage(in, model); + op.filter(in, out); + DataBuffer dbout = out.getRaster().getDataBuffer(); + super.setPixels(0, 0, w, h, model, ((DataBufferInt)dbout).getData(), 0, + scansize); + } +} diff --git a/libjava/java/awt/image/ByteLookupTable.java b/libjava/java/awt/image/ByteLookupTable.java index 572f6e9..f022191 100644 --- a/libjava/java/awt/image/ByteLookupTable.java +++ b/libjava/java/awt/image/ByteLookupTable.java @@ -61,7 +61,7 @@ public class ByteLookupTable extends LookupTable * * @param offset Offset to be subtracted. * @param data Array of lookup tables. - * @exception IllegalArgumentException if offset < 0 or data.length < 1. + * @exception IllegalArgumentException if offset < 0 or data.length < 1. */ public ByteLookupTable(int offset, byte[][] data) throws IllegalArgumentException @@ -78,7 +78,7 @@ public class ByteLookupTable extends LookupTable * * @param offset Offset to be subtracted. * @param data Lookup table for all components. - * @exception IllegalArgumentException if offset < 0. + * @exception IllegalArgumentException if offset < 0. */ public ByteLookupTable(int offset, byte[] data) throws IllegalArgumentException @@ -87,7 +87,11 @@ public class ByteLookupTable extends LookupTable this.data = new byte[][] {data}; } - /** Return the lookup tables. */ + /** + * Return the lookup tables. + * + * @return the tables + */ public final byte[][] getTable() { return data; @@ -107,14 +111,14 @@ public class ByteLookupTable extends LookupTable * translation arrays. * * @param src Component values of a pixel. - * @param dest Destination array for values, or null. + * @param dst Destination array for values, or null. * @return Translated values for the pixel. */ public int[] lookupPixel(int[] src, int[] dst) throws ArrayIndexOutOfBoundsException { if (dst == null) - dst = new int[numComponents]; + dst = new int[src.length]; if (data.length == 1) for (int i=0; i < src.length; i++) @@ -140,14 +144,14 @@ public class ByteLookupTable extends LookupTable * translation arrays. * * @param src Component values of a pixel. - * @param dest Destination array for values, or null. + * @param dst Destination array for values, or null. * @return Translated values for the pixel. */ public byte[] lookupPixel(byte[] src, byte[] dst) throws ArrayIndexOutOfBoundsException { if (dst == null) - dst = new byte[numComponents]; + dst = new byte[src.length]; if (data.length == 1) for (int i=0; i < src.length; i++) diff --git a/libjava/java/awt/image/ColorConvertOp.java b/libjava/java/awt/image/ColorConvertOp.java new file mode 100644 index 0000000..5fcb37c --- /dev/null +++ b/libjava/java/awt/image/ColorConvertOp.java @@ -0,0 +1,319 @@ +/* ColorModel.java -- + Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.awt.image; + +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.color.ColorSpace; +import java.awt.color.ICC_ColorSpace; +import java.awt.color.ICC_Profile; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +/** + * ColorConvertOp is a filter for converting an image from one colorspace to + * another colorspace. The filter can convert the image through a sequence + * of colorspaces or just from source to destination. + * + * Color conversion is done on the color components without alpha. Thus + * if a BufferedImage has alpha premultiplied, this is divided out before + * color conversion, and premultiplication applied if the destination + * requires it. + * + * Color rendering and dithering hints may be applied if specified. This is + * likely platform-dependent. + * + * @author jlquinn@optonline.net + */ +public class ColorConvertOp implements BufferedImageOp, RasterOp +{ + private ColorSpace srccs; + private ColorSpace dstcs; + private RenderingHints hints; + private ICC_Profile[] profiles; + private ColorSpace[] spaces; + private boolean rasterValid; + + + /** + * Convert BufferedImage through a ColorSpace. + * + * This filter version is only valid for BufferedImages. The source image + * is converted to cspace. If the destination is not null, it is then + * converted to the destination colorspace. Normally this filter will only + * be used with a null destination. + * + * @param cspace The target color space. + * @param hints Rendering hints to use in conversion, or null. + */ + public ColorConvertOp(ColorSpace cspace, RenderingHints hints) + { + if (cspace == null) + throw new NullPointerException(); + spaces = new ColorSpace[]{cspace}; + this.hints = hints; + rasterValid = false; + } + + public ColorConvertOp(ColorSpace srcCspace, ColorSpace dstCspace, + RenderingHints hints) + { + if (srcCspace == null || dstCspace == null) + throw new NullPointerException(); + spaces = new ColorSpace[]{srcCspace, dstCspace}; + this.hints = hints; + } + + /** + * Convert from a source image destination image color space. + * + * This constructor builds a ColorConvertOp from an array of ICC_Profiles. + * The source image will be converted through the sequence of color spaces + * defined by the profiles. If the sequence of profiles doesn't give a + * well-defined conversion, throws IllegalArgumentException. + * + * NOTE: Sun's docs don't clearly define what a well-defined conversion is + * - or perhaps someone smarter can come along and sort it out. + * + * For BufferedImages, when the first and last profiles match the + * requirements of the source and destination color space respectively, the + * corresponding conversion is unnecessary. TODO: code this up. I don't + * yet understand how you determine this. + * + * For Rasters, the first and last profiles must have the same number of + * bands as the source and destination Rasters, respectively. If this is + * not the case, or there fewer than 2 profiles, an IllegalArgumentException + * will be thrown. + * + * @param profiles + * @param hints + */ + public ColorConvertOp(ICC_Profile[] profiles, RenderingHints hints) + { + if (profiles == null) + throw new NullPointerException(); + this.hints = hints; + this.profiles = profiles; + // TODO: Determine if this is well-defined. + // Create colorspace array with space for src and dest colorspace + spaces = new ColorSpace[profiles.length]; + for (int i = 0; i < profiles.length; i++) + spaces[i] = new ICC_ColorSpace(profiles[i]); + } + + /** Convert from source image color space to destination image color space. + * + * Only valid for BufferedImage objects, this Op converts from the source + * color space to the destination color space. The destination can't be + * null for this operation. + * + * @param hints Rendering hints to use during conversion, or null. + */ + public ColorConvertOp(RenderingHints hints) + { + this.hints = hints; + srccs = null; + dstcs = null; + rasterValid = false; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, + java.awt.image.BufferedImage) + */ + public final BufferedImage filter(BufferedImage src, BufferedImage dst) + { + // TODO: The plan is to create a scanline buffer for intermediate buffers. + // For now we just suck it up and create intermediate buffers. + + if (dst == null && spaces.length == 0) + throw new IllegalArgumentException(); + + // Make sure input isn't premultiplied by alpha + if (src.isAlphaPremultiplied()) + { + BufferedImage tmp = createCompatibleDestImage(src, src.getColorModel()); + copyimage(src, tmp); + tmp.coerceData(false); + src = tmp; + } + + ColorModel scm = src.getColorModel(); + for (int i = 0; i < spaces.length; i++) + { + ColorModel cm = scm.cloneColorModel(spaces[i]); + BufferedImage tmp = createCompatibleDestImage(src, cm); + copyimage(src, tmp); + src = tmp; + } + + // Intermediate conversions leave result in src + if (dst == null) + return src; + + // Apply final conversion + copyimage(src, dst); + return dst; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) + */ + public BufferedImage createCompatibleDestImage(BufferedImage src, + ColorModel dstCM) + { + // FIXME: set properties to those in src + return new BufferedImage(dstCM, + src.getRaster().createCompatibleWritableRaster(), + src.isPremultiplied, + null); + } + + public final ICC_Profile[] getICC_Profiles() + { + return profiles; + } + + /** Return the rendering hints for this op. */ + public final RenderingHints getRenderingHints() + { + return hints; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster) + */ + public final WritableRaster filter(Raster src, WritableRaster dest) + { + if (!rasterValid) + throw new IllegalArgumentException(); + + // Need to iterate through each color space - there must be at least 2 + for (int i = 1; i < spaces.length - 1; i++) + { + // FIXME: this is wrong. tmp needs to have the same number of bands as + // spaces[i] has. + WritableRaster tmp = createCompatibleDestRaster(src); + copyraster(src, spaces[i - 1], tmp, spaces[i]); + src = tmp; + } + + // FIXME: this is wrong. dst needs to have the same number of bands as + // spaces[i] has. + if (dest == null) + dest = createCompatibleDestRaster(src); + copyraster(src, spaces[spaces.length - 2], + dest, spaces[spaces.length - 1]); + + return dest; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) + */ + public WritableRaster createCompatibleDestRaster(Raster src) + { + return src.createCompatibleWritableRaster(); + } + + /** Return corresponding destination point for source point. + * + * LookupOp will return the value of src unchanged. + * @param src The source point. + * @param dst The destination point. + * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) + */ + public final Point2D getPoint2D(Point2D src, Point2D dst) + { + if (dst == null) return (Point2D)src.clone(); + dst.setLocation(src); + return dst; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage) + */ + public final Rectangle2D getBounds2D(BufferedImage src) + { + return src.getRaster().getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster) + */ + public final Rectangle2D getBounds2D(Raster src) + { + return src.getBounds(); + } + + // According to Sven de Marothy, we need to copy the src into the dest + // using Graphics2D, in order to use the rendering hints. + private void copyimage(BufferedImage src, BufferedImage dst) + { + Graphics2D gg = dst.createGraphics(); + gg.setRenderingHints(hints); + gg.drawImage(src, 0, 0, null); + gg.dispose(); + } + + private void copyraster(Raster src, ColorSpace scs, WritableRaster dst, + ColorSpace dcs) + { + float[] sbuf = new float[src.getNumBands()]; + + if (hints.get(RenderingHints.KEY_COLOR_RENDERING) == + RenderingHints.VALUE_COLOR_RENDER_QUALITY) + { + // use cie for accuracy + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + dst.setPixel(x, y, + dcs.fromCIEXYZ(scs.toCIEXYZ(src.getPixel(x, y, sbuf)))); + } + else + { + // use rgb - it's probably faster + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + dst.setPixel(x, y, + dcs.fromRGB(scs.toRGB(src.getPixel(x, y, sbuf)))); + } + } + +} diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java index 87ab942..11615fd 100644 --- a/libjava/java/awt/image/ColorModel.java +++ b/libjava/java/awt/image/ColorModel.java @@ -1,4 +1,5 @@ -/* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation +/* ColorModel.java -- + Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -37,11 +38,13 @@ exception statement from your version. */ package java.awt.image; -import java.util.Arrays; +import gnu.java.awt.Buffers; + import java.awt.Point; import java.awt.Transparency; import java.awt.color.ColorSpace; -import gnu.java.awt.Buffers; +import java.lang.reflect.Constructor; +import java.util.Arrays; /** * A color model operates with colors in several formats: @@ -76,8 +79,8 @@ import gnu.java.awt.Buffers; * * </ul> * - * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> - * @author C. Brian Jones <cbj@gnu.org> + * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) + * @author C. Brian Jones (cbj@gnu.org) */ public abstract class ColorModel implements Transparency { @@ -108,7 +111,7 @@ public abstract class ColorModel implements Transparency * Constructs the default color model. The default color model * can be obtained by calling <code>getRGBdefault</code> of this * class. - * @param b the number of bits wide used for bit size of pixel values + * @param bits the number of bits wide used for bit size of pixel values */ public ColorModel(int bits) { @@ -156,6 +159,32 @@ public abstract class ColorModel implements Transparency this.transferType = transferType; } + // This is a hook for ColorConvertOp to create a colormodel with + // a new colorspace + ColorModel cloneColorModel(ColorSpace cspace) + { + Class cls = this.getClass(); + ColorModel cm; + try { + // This constructor will exist. + Constructor ctor = + cls.getConstructor(new Class[]{int.class, int[].class, + ColorSpace.class, boolean.class, + boolean.class, int.class, int.class}); + cm = (ColorModel)ctor. + newInstance(new Object[]{new Integer(pixel_bits), + bits, cspace, Boolean.valueOf(hasAlpha), + Boolean.valueOf(isAlphaPremultiplied), + new Integer(transparency), + new Integer(transferType)}); + } + catch (Exception e) + { + throw new IllegalArgumentException(); + } + return cm; + } + public void finalize() { // Do nothing here. @@ -294,7 +323,7 @@ public abstract class ColorModel implements Transparency * This method is typically overriden in subclasses to provide a * more efficient implementation. * - * @param array of transferType containing a single pixel. The + * @param inData array of transferType containing a single pixel. The * pixel should be encoded in the natural way of the color model. */ public int getRed(Object inData) @@ -508,40 +537,89 @@ public abstract class ColorModel implements Transparency * <code>(pixel == cm.getDataElement(cm.getComponents(pixel, null, * 0), 0))</code>. * - * This method is typically overriden in subclasses to provide a - * more efficient implementation. + * This method is overriden in subclasses since this abstract class throws + * UnsupportedOperationException(). * - * @param arrays of unnormalized component samples of single - * pixel. The scale and multiplication state of the samples are - * according to the color model. Each component sample is stored - * as a separate element in the array. + * @param components Array of unnormalized component samples of single + * pixel. The scale and multiplication state of the samples are according + * to the color model. Each component sample is stored as a separate element + * in the array. + * @param offset Position of the first value of the pixel in components. * * @return pixel value encoded according to the color model. */ public int getDataElement(int[] components, int offset) { - // subclasses has to implement this method. + // subclasses have to implement this method. throw new UnsupportedOperationException(); } + /** + * Converts the normalized component samples from an array to a pixel + * value. I.e. composes the pixel from component samples, but does not + * perform any color conversion or scaling of the samples. + * + * This method is typically overriden in subclasses to provide a + * more efficient implementation. The method provided by this abstract + * class converts the components to unnormalized form and returns + * getDataElement(int[], int). + * + * @param components Array of normalized component samples of single pixel. + * The scale and multiplication state of the samples are according to the + * color model. Each component sample is stored as a separate element in the + * array. + * @param offset Position of the first value of the pixel in components. + * + * @return pixel value encoded according to the color model. + * @since 1.4 + */ public int getDataElement (float[] components, int offset) { - // subclasses has to implement this method. - throw new UnsupportedOperationException(); + return + getDataElement(getUnnormalizedComponents(components, offset, null, 0), + 0); } public Object getDataElements(int[] components, int offset, Object obj) { - // subclasses has to implement this method. + // subclasses have to implement this method. throw new UnsupportedOperationException(); } - public int getDataElements (float[] components, Object obj) + /** + * Converts the normalized component samples from an array to an array of + * TransferType values. I.e. composes the pixel from component samples, but + * does not perform any color conversion or scaling of the samples. + * + * If obj is null, a new array of TransferType is allocated and returned. + * Otherwise the results are stored in obj and obj is returned. If obj is + * not long enough, ArrayIndexOutOfBounds is thrown. If obj is not an array + * of primitives, ClassCastException is thrown. + * + * This method is typically overriden in subclasses to provide a + * more efficient implementation. The method provided by this abstract + * class converts the components to unnormalized form and returns + * getDataElement(int[], int, Object). + * + * @param components Array of normalized component samples of single pixel. + * The scale and multiplication state of the samples are according to the + * color model. Each component sample is stored as a separate element in the + * array. + * @param offset Position of the first value of the pixel in components. + * @param obj Array of TransferType or null. + * + * @return pixel value encoded according to the color model. + * @throws ArrayIndexOutOfBounds + * @throws ClassCastException + * @since 1.4 + */ + public Object getDataElements(float[] components, int offset, Object obj) { - // subclasses has to implement this method. - throw new UnsupportedOperationException(); + return + getDataElements(getUnnormalizedComponents(components, offset, null, 0), + 0, obj); } - + public boolean equals(Object obj) { if (!(obj instanceof ColorModel)) return false; diff --git a/libjava/java/awt/image/ComponentColorModel.java b/libjava/java/awt/image/ComponentColorModel.java index 24d8b8e..2b06532 100644 --- a/libjava/java/awt/image/ComponentColorModel.java +++ b/libjava/java/awt/image/ComponentColorModel.java @@ -1,4 +1,5 @@ -/* Copyright (C) 2000, 2002, 2004 Free Software Foundation +/* ComponentColorModel.java -- + Copyright (C) 2000, 2002, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -37,9 +38,10 @@ exception statement from your version. */ package java.awt.image; +import gnu.java.awt.Buffers; + import java.awt.Point; import java.awt.color.ColorSpace; -import gnu.java.awt.Buffers; public class ComponentColorModel extends ColorModel { @@ -60,6 +62,32 @@ public class ComponentColorModel extends ColorModel transparency, transferType); } + /** + * Construct a new ComponentColorModel. + * + * This constructor makes all bits of each sample significant, so for a + * transferType of DataBuffer.BYTE, the bits per sample is 8, etc. If + * both hasAlpha and isAlphaPremultiplied are true, color samples are + * assumed to be premultiplied by the alpha component. Transparency may be + * one of OPAQUE, BITMASK, or TRANSLUCENT. + * + * @param colorSpace The colorspace for this color model. + * @param hasAlpha True if there is an alpha component. + * @param isAlphaPremultiplied True if colors are already multiplied by + * alpha. + * @param transparency The type of alpha values. + * @param transferType Data type of pixel sample values. + * @since 1.4 + */ + public ComponentColorModel(ColorSpace colorSpace, + boolean hasAlpha, + boolean isAlphaPremultiplied, + int transparency, int transferType) + { + this(colorSpace, null, hasAlpha, isAlphaPremultiplied, + transparency, transferType); + } + public int getRed(int pixel) { if (getNumComponents()>1) throw new IllegalArgumentException(); @@ -95,12 +123,6 @@ public class ComponentColorModel extends ColorModel } - /* FIXME: Is the values returned from toRGB() in the [0.0, 1.0] or the - [0.0, 256) range? - - we assume it is in the [0.0, 1.0] range along with the - other color spaces. */ - /* Note, it's OK to pass a to large array to toRGB(). Extra elements are ignored. */ diff --git a/libjava/java/awt/image/ComponentSampleModel.java b/libjava/java/awt/image/ComponentSampleModel.java index c7b08b9..0665f40 100644 --- a/libjava/java/awt/image/ComponentSampleModel.java +++ b/libjava/java/awt/image/ComponentSampleModel.java @@ -41,6 +41,21 @@ import gnu.java.awt.Buffers; /* FIXME: This class does not yet support data type TYPE_SHORT */ /** + * ComponentSampleModel supports a flexible organization of pixel samples in + * memory, permitting pixel samples to be interleaved by band, by scanline, + * and by pixel. + * + * A DataBuffer for this sample model has K banks of data. Pixels have N + * samples, so there are N bands in the DataBuffer. Each band is completely + * contained in one bank of data, but a bank may contain more than one band. + * Each pixel sample is stored in a single data element. + * + * Within a bank, each band begins at an offset stored in bandOffsets. The + * banks containing the band is given by bankIndices. Within the bank, there + * are three dimensions - band, pixel, and scanline. The dimension ordering + * is controlled by bandOffset, pixelStride, and scanlineStride, which means + * that any combination of interleavings is supported. + * * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> */ public class ComponentSampleModel extends SampleModel @@ -86,6 +101,7 @@ public class ComponentSampleModel extends SampleModel this.bandOffsets = bandOffsets; this.bankIndices = bankIndices; + this.numBanks = 0; for (int b=0; b<bankIndices.length; b++) this.numBanks = Math.max(this.numBanks, bankIndices[b]+1); @@ -249,6 +265,18 @@ public class ComponentSampleModel extends SampleModel } return outUShort; + case DataBuffer.TYPE_SHORT: + DataBufferShort inShort = (DataBufferShort) data; + short[] outShort = (short[]) obj; + if (outShort == null) outShort = new short[numBands]; + + for (int b=0; b<numBands; b++) + { + int dOffset = totalBandDataOffsets[b]; + outShort[b] = inShort.getData(bankIndices[b])[dOffset]; + } + return outShort; + case DataBuffer.TYPE_INT: DataBufferInt inInt = (DataBufferInt) data; int[] outInt = (int[]) obj; @@ -260,8 +288,31 @@ public class ComponentSampleModel extends SampleModel outInt[b] = inInt.getData(bankIndices[b])[dOffset]; } return outInt; - - // FIXME: Fill in the other possible types. + + case DataBuffer.TYPE_FLOAT: + DataBufferFloat inFloat = (DataBufferFloat) data; + float[] outFloat = (float[]) obj; + if (outFloat == null) outFloat = new float[numBands]; + + for (int b=0; b<numBands; b++) + { + int dOffset = totalBandDataOffsets[b]; + outFloat[b] = inFloat.getData(bankIndices[b])[dOffset]; + } + return outFloat; + + case DataBuffer.TYPE_DOUBLE: + DataBufferDouble inDouble = (DataBufferDouble) data; + double[] outDouble = (double[]) obj; + if (outDouble == null) outDouble = new double[numBands]; + + for (int b=0; b<numBands; b++) + { + int dOffset = totalBandDataOffsets[b]; + outDouble[b] = inDouble.getData(bankIndices[b])[dOffset]; + } + return outDouble; + default: throw new IllegalStateException("unknown transfer type " + getTransferType()); @@ -433,6 +484,16 @@ public class ComponentSampleModel extends SampleModel return; } + case DataBuffer.TYPE_SHORT: + { + DataBufferShort out = (DataBufferShort) data; + short[] in = (short[]) obj; + + for (int b=0; b<numBands; b++) + out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b]; + + return; + } case DataBuffer.TYPE_INT: { DataBufferInt out = (DataBufferInt) data; @@ -443,6 +504,26 @@ public class ComponentSampleModel extends SampleModel return; } + case DataBuffer.TYPE_FLOAT: + { + DataBufferFloat out = (DataBufferFloat) data; + float[] in = (float[]) obj; + + for (int b=0; b<numBands; b++) + out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b]; + + return; + } + case DataBuffer.TYPE_DOUBLE: + { + DataBufferDouble out = (DataBufferDouble) data; + double[] in = (double[]) obj; + + for (int b=0; b<numBands; b++) + out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b]; + + return; + } default: throw new UnsupportedOperationException("transfer type not " + "implemented"); diff --git a/libjava/java/awt/image/ConvolveOp.java b/libjava/java/awt/image/ConvolveOp.java new file mode 100644 index 0000000..c793eee --- /dev/null +++ b/libjava/java/awt/image/ConvolveOp.java @@ -0,0 +1,341 @@ +/* Copyright (C) 2004 Free Software Foundation -- ConvolveOp + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +/* + * Created on Nov 1, 2004 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package java.awt.image; + +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +/** + * Convolution filter. + * + * ConvolveOp convolves the source image with a Kernel to generate a + * destination image. This involves multiplying each pixel and its neighbors + * with elements in the kernel to compute a new pixel. + * + * Each band in a Raster is convolved and copied to the destination Raster. + * + * For BufferedImages, convolution is applied to all components. If the + * source is not premultiplied, the data will be premultiplied before + * convolving. Premultiplication will be undone if the destination is not + * premultiplied. Color conversion will be applied if needed. + * + * @author jlquinn@optonline.net + */ +public class ConvolveOp implements BufferedImageOp, RasterOp +{ + /** Edge pixels are set to 0. */ + public static final int EDGE_ZERO_FILL = 0; + + /** Edge pixels are copied from the source. */ + public static final int EDGE_NO_OP = 1; + + private Kernel kernel; + private int edge; + private RenderingHints hints; + + /** + * Construct a ConvolveOp. + * + * The edge condition specifies that pixels outside the area that can be + * filtered are either set to 0 or copied from the source image. + * + * @param kernel The kernel to convolve with. + * @param edgeCondition Either EDGE_ZERO_FILL or EDGE_NO_OP. + * @param hints Rendering hints for color conversion, or null. + */ + public ConvolveOp(Kernel kernel, + int edgeCondition, + RenderingHints hints) + { + this.kernel = kernel; + edge = edgeCondition; + this.hints = hints; + } + + /** + * Construct a ConvolveOp. + * + * The edge condition defaults to EDGE_ZERO_FILL. + * + * @param kernel The kernel to convolve with. + */ + public ConvolveOp(Kernel kernel) + { + this.kernel = kernel; + edge = EDGE_ZERO_FILL; + hints = null; + } + + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, + * java.awt.image.BufferedImage) + */ + public BufferedImage filter(BufferedImage src, BufferedImage dst) + { + if (src == dst) + throw new IllegalArgumentException(); + + if (dst == null) + dst = createCompatibleDestImage(src, src.getColorModel()); + + // Make sure source image is premultiplied + BufferedImage src1 = src; + if (!src.isPremultiplied) + { + src1 = createCompatibleDestImage(src, src.getColorModel()); + src.copyData(src1.getRaster()); + src1.coerceData(true); + } + + BufferedImage dst1 = dst; + if (!src.getColorModel().equals(dst.getColorModel())) + dst1 = createCompatibleDestImage(src, src.getColorModel()); + + filter(src1.getRaster(), dst1.getRaster()); + + if (dst1 != dst) + { + // Convert between color models. + // TODO Check that premultiplied alpha is handled correctly here. + Graphics2D gg = dst.createGraphics(); + gg.setRenderingHints(hints); + gg.drawImage(dst1, 0, 0, null); + gg.dispose(); + } + + return dst; + } + + /* (non-Javadoc) + * @see + * java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, + * java.awt.image.ColorModel) + */ + public BufferedImage createCompatibleDestImage(BufferedImage src, + ColorModel dstCM) + { + // FIXME: set properties to those in src + return new BufferedImage(dstCM, + src.getRaster().createCompatibleWritableRaster(), + src.isPremultiplied, null); + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getRenderingHints() + */ + public RenderingHints getRenderingHints() + { + return hints; + } + + /** + * @return The edge condition. + */ + public int getEdgeCondition() + { + return edge; + } + + /** + * @return The convolution kernel. + */ + public Kernel getKernel() + { + return kernel; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, + * java.awt.image.WritableRaster) + */ + public WritableRaster filter(Raster src, WritableRaster dest) { + if (src.numBands != dest.numBands) + throw new ImagingOpException(null); + if (src == dest) + throw new IllegalArgumentException(); + if (src.getWidth() < kernel.getWidth() || + src.getHeight() < kernel.getHeight()) + throw new ImagingOpException(null); + + if (dest == null) + dest = createCompatibleDestRaster(src); + + // Deal with bottom edge + if (edge == EDGE_ZERO_FILL) + { + float[] zeros = new float[src.getNumBands() * src.getWidth() + * (kernel.getYOrigin() - 1)]; + Arrays.fill(zeros, 0); + dest.setPixels(src.getMinX(), src.getMinY(), src.getWidth(), + kernel.getYOrigin() - 1, zeros); + } + else + { + float[] vals = new float[src.getNumBands() * src.getWidth() + * (kernel.getYOrigin() - 1)]; + src.getPixels(src.getMinX(), src.getMinY(), src.getWidth(), + kernel.getYOrigin() - 1, vals); + dest.setPixels(src.getMinX(), src.getMinY(), src.getWidth(), + kernel.getYOrigin() - 1, vals); + } + + // Handle main section + float[] kvals = kernel.getKernelData(null); + + float[] tmp = new float[kernel.getWidth() * kernel.getHeight()]; + for (int y = src.getMinY() + kernel.getYOrigin(); + y < src.getMinY() + src.getHeight() - kernel.getYOrigin() / 2; y++) + { + // Handle unfiltered edge pixels at start of line + float[] t1 = new float[(kernel.getXOrigin() - 1) * src.getNumBands()]; + if (edge == EDGE_ZERO_FILL) + Arrays.fill(t1, 0); + else + src.getPixels(src.getMinX(), y, kernel.getXOrigin() - 1, 1, t1); + dest.setPixels(src.getMinX(), y, kernel.getXOrigin() - 1, 1, t1); + + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + { + // FIXME: This needs a much more efficient implementation + for (int b = 0; b < src.getNumBands(); b++) + { + float v = 0; + src.getSamples(x, y, kernel.getWidth(), kernel.getHeight(), b, tmp); + for (int i=0; i < tmp.length; i++) + v += tmp[i] * kvals[i]; + dest.setSample(x, y, b, v); + } + } + + // Handle unfiltered edge pixels at end of line + float[] t2 = new float[(kernel.getWidth() / 2) * src.getNumBands()]; + if (edge == EDGE_ZERO_FILL) + Arrays.fill(t2, 0); + else + src.getPixels(src.getMinX() + src.getWidth() + - (kernel.getWidth() / 2), + y, kernel.getWidth() / 2, 1, t2); + dest.setPixels(src.getMinX() + src.getWidth() - (kernel.getWidth() / 2), + y, kernel.getWidth() / 2, 1, t2); + } + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x< src.getWidth() + src.getMinX(); x++) + { + + } + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x< src.getWidth() + src.getMinX(); x++) + { + + } + + // Handle top edge + if (edge == EDGE_ZERO_FILL) + { + float[] zeros = new float[src.getNumBands() * src.getWidth() * + (kernel.getHeight() / 2)]; + Arrays.fill(zeros, 0); + dest.setPixels(src.getMinX(), + src.getHeight() + src.getMinY() - (kernel.getHeight() / 2), + src.getWidth(), kernel.getHeight() / 2, zeros); + } + else + { + float[] vals = new float[src.getNumBands() * src.getWidth() * + (kernel.getHeight() / 2)]; + src.getPixels(src.getMinX(), + src.getHeight() + src.getMinY() + - (kernel.getHeight() / 2), + src.getWidth(), kernel.getHeight() / 2, vals); + dest.setPixels(src.getMinX(), + src.getHeight() + src.getMinY() + - (kernel.getHeight() / 2), + src.getWidth(), kernel.getHeight() / 2, vals); + } + + return dest; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) + */ + public WritableRaster createCompatibleDestRaster(Raster src) + { + return src.createCompatibleWritableRaster(); + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage) + */ + public Rectangle2D getBounds2D(BufferedImage src) + { + return src.getRaster().getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster) + */ + public Rectangle2D getBounds2D(Raster src) + { + return src.getBounds(); + } + + /** Return corresponding destination point for source point. + * + * ConvolveOp will return the value of src unchanged. + * @param src The source point. + * @param dst The destination point. + * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, + * java.awt.geom.Point2D) + */ + public Point2D getPoint2D(Point2D src, Point2D dst) + { + if (dst == null) return (Point2D)src.clone(); + dst.setLocation(src); + return dst; + } +} diff --git a/libjava/java/awt/image/CropImageFilter.java b/libjava/java/awt/image/CropImageFilter.java index c9a170b..a006d26 100644 --- a/libjava/java/awt/image/CropImageFilter.java +++ b/libjava/java/awt/image/CropImageFilter.java @@ -1,5 +1,5 @@ /* CropImageFilter.java -- Java class for cropping image filter - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,11 +38,10 @@ exception statement from your version. */ package java.awt.image; -import java.util.Hashtable; import java.awt.Rectangle; +import java.util.Hashtable; /** - * <br> * Currently this filter does almost nothing and needs to be implemented. * * @author C. Brian Jones (cbj@gnu.org) diff --git a/libjava/java/awt/image/DataBuffer.java b/libjava/java/awt/image/DataBuffer.java index 967e1a2..b921953 100644 --- a/libjava/java/awt/image/DataBuffer.java +++ b/libjava/java/awt/image/DataBuffer.java @@ -45,12 +45,45 @@ package java.awt.image; */ public abstract class DataBuffer { + /** + * A constant representng a data type that uses <code>byte</code> primitives + * as the storage unit. + */ public static final int TYPE_BYTE = 0; + + /** + * A constant representng a data type that uses <code>short</code> + * primitives as the storage unit. + */ public static final int TYPE_USHORT = 1; + + /** + * A constant representng a data type that uses <code>short</code> + * primitives as the storage unit. + */ public static final int TYPE_SHORT = 2; + + /** + * A constant representng a data type that uses <code>int</code> + * primitives as the storage unit. + */ public static final int TYPE_INT = 3; + + /** + * A constant representng a data type that uses <code>float</code> + * primitives as the storage unit. + */ public static final int TYPE_FLOAT = 4; + + /** + * A constant representng a data type that uses <code>double</code> + * primitives as the storage unit. + */ public static final int TYPE_DOUBLE = 5; + + /** + * A constant representng an undefined data type. + */ public static final int TYPE_UNDEFINED = 32; /** The type of the data elements stored in the data buffer. */ @@ -68,18 +101,57 @@ public abstract class DataBuffer /** Offset into each bank. */ protected int[] offsets; + /** + * Creates a new <code>DataBuffer</code> with the specified data type and + * size. The <code>dataType</code> should be one of the constants + * {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, {@link #TYPE_USHORT}, + * {@link #TYPE_INT}, {@link #TYPE_FLOAT} and {@link #TYPE_DOUBLE}. + * <p> + * The physical (array-based) storage is allocated by a subclass. + * + * @param dataType the data type. + * @param size the number of elements in the buffer. + */ protected DataBuffer(int dataType, int size) { this.dataType = dataType; this.size = size; } + /** + * Creates a new <code>DataBuffer</code> with the specified data type, + * size and number of banks. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * {@link #TYPE_DOUBLE}. + * <p> + * The physical (array-based) storage is allocated by a subclass. + * + * @param dataType the data type. + * @param size the number of elements in the buffer. + * @param numBanks the number of data banks. + */ protected DataBuffer(int dataType, int size, int numBanks) { this(dataType, size); banks = numBanks; offsets = new int[numBanks]; } + /** + * Creates a new <code>DataBuffer</code> with the specified data type, + * size and number of banks. An offset (which applies to all banks) is + * also specified. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * {@link #TYPE_DOUBLE}. + * <p> + * The physical (array-based) storage is allocated by a subclass. + * + * @param dataType the data type. + * @param size the number of elements in the buffer. + * @param numBanks the number of data banks. + * @param offset the offset to the first element for all banks. + */ protected DataBuffer(int dataType, int size, int numBanks, int offset) { this(dataType, size, numBanks); @@ -88,6 +160,24 @@ public abstract class DataBuffer this.offset = offset; } + /** + * Creates a new <code>DataBuffer</code> with the specified data type, + * size and number of banks. An offset (which applies to all banks) is + * also specified. The <code>dataType</code> should be one of + * the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * {@link #TYPE_DOUBLE}. + * <p> + * The physical (array-based) storage is allocated by a subclass. + * + * @param dataType the data type. + * @param size the number of elements in the buffer. + * @param numBanks the number of data banks. + * @param offsets the offsets to the first element for all banks. + * + * @throws ArrayIndexOutOfBoundsException if + * <code>numBanks != offsets.length</code>. + */ protected DataBuffer(int dataType, int size, int numBanks, int[] offsets) { this(dataType, size); if (numBanks != offsets.length) @@ -99,6 +189,17 @@ public abstract class DataBuffer offset = offsets[0]; } + /** + * Returns the size (number of bits) of the specified data type. Valid types + * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * {@link #TYPE_DOUBLE}. + * + * @param dataType the data type. + * @return The number of bits for the specified data type. + * @throws IllegalArgumentException if <code>dataType < 0</code> or + * <code>dataType > TYPE_DOUBLE</code>. + */ public static int getDataTypeSize(int dataType) { // Maybe this should be a lookup table instead. switch (dataType) @@ -118,21 +219,45 @@ public abstract class DataBuffer } } + /** + * Returns the type of the data elements in the data buffer. Valid types + * are defined by the constants {@link #TYPE_BYTE}, {@link #TYPE_SHORT}, + * {@link #TYPE_USHORT}, {@link #TYPE_INT}, {@link #TYPE_FLOAT} and + * {@link #TYPE_DOUBLE}. + * + * @return The type. + */ public int getDataType() { return dataType; } + /** + * Returns the size of the data buffer. + * + * @return The size. + */ public int getSize() { return size; } + /** + * Returns the element offset for the first data bank. + * + * @return The element offset. + */ public int getOffset() { return offset; } + /** + * Returns the offsets for all the data banks used by this + * <code>DataBuffer</code>. + * + * @return The offsets. + */ public int[] getOffsets() { if (offsets == null) @@ -144,60 +269,166 @@ public abstract class DataBuffer return offsets; } + /** + * Returns the number of data banks for this <code>DataBuffer</code>. + * @return The number of data banks. + */ public int getNumBanks() { return banks; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return getElem(0, i); } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public abstract int getElem(int bank, int i); + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { setElem(0, i, val); } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public abstract void setElem(int bank, int i, int val); + /** + * Returns an element from the first data bank, converted to a + * <code>float</code>. The offset (specified in the constructor) is added + * to <code>i</code> before accessing the underlying data array. + * + * @param i the element index. + * @return The element. + */ public float getElemFloat(int i) { return getElem(i); } + /** + * Returns an element from a particular data bank, converted to a + * <code>float</code>. The offset (specified in the constructor) is + * added to <code>i</code> before accessing the underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public float getElemFloat(int bank, int i) { return getElem(bank, i); } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElemFloat(int i, float val) { setElem(i, (int) val); } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElemFloat(int bank, int i, float val) { setElem(bank, i, (int) val); } + /** + * Returns an element from the first data bank, converted to a + * <code>double</code>. The offset (specified in the constructor) is added + * to <code>i</code> before accessing the underlying data array. + * + * @param i the element index. + * @return The element. + */ public double getElemDouble(int i) { return getElem(i); } + /** + * Returns an element from a particular data bank, converted to a + * <code>double</code>. The offset (specified in the constructor) is + * added to <code>i</code> before accessing the underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public double getElemDouble(int bank, int i) { return getElem(bank, i); } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElemDouble(int i, double val) { setElem(i, (int) val); } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElemDouble(int bank, int i, double val) { setElem(bank, i, (int) val); diff --git a/libjava/java/awt/image/DataBufferByte.java b/libjava/java/awt/image/DataBufferByte.java index 84df551..c56be6b 100644 --- a/libjava/java/awt/image/DataBufferByte.java +++ b/libjava/java/awt/image/DataBufferByte.java @@ -54,12 +54,27 @@ public final class DataBufferByte extends DataBuffer private byte[] data; private byte[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>byte</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferByte(int size) { - super(TYPE_BYTE, size); + super(TYPE_BYTE, size, 1, 0); + bankData = new byte[1][]; data = new byte[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>byte</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferByte(int size, int numBanks) { super(TYPE_BYTE, size, numBanks); @@ -67,18 +82,53 @@ public final class DataBufferByte extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + */ public DataBufferByte(byte[] dataArray, int size) { - super(TYPE_BYTE, size); + super(TYPE_BYTE, size, 1, 0); + bankData = new byte[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + */ public DataBufferByte(byte[] dataArray, int size, int offset) { super(TYPE_BYTE, size, 1, offset); + bankData = new byte[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferByte(byte[][] dataArray, int size) { super(TYPE_BYTE, size, dataArray.length); @@ -86,6 +136,17 @@ public final class DataBufferByte extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferByte(byte[][] dataArray, int size, int[] offsets) { super(TYPE_BYTE, size, dataArray.length, offsets); @@ -93,37 +154,87 @@ public final class DataBufferByte extends DataBuffer data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public byte[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public byte[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public byte[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return data[i+offset] & 0xff; // get unsigned byte as int } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { // get unsigned byte as int return bankData[bank][i+offsets[bank]] & 0xff; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { data[i+offset] = (byte) val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { bankData[bank][i+offsets[bank]] = (byte) val; diff --git a/libjava/java/awt/image/DataBufferDouble.java b/libjava/java/awt/image/DataBufferDouble.java index b1291f4..305cb00 100644 --- a/libjava/java/awt/image/DataBufferDouble.java +++ b/libjava/java/awt/image/DataBufferDouble.java @@ -58,12 +58,27 @@ public final class DataBufferDouble private double[] data; private double[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>double</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferDouble(int size) { - super(TYPE_DOUBLE, size); + super(TYPE_DOUBLE, size, 1, 0); + bankData = new double[1][]; data = new double[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>double</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferDouble(int size, int numBanks) { super(TYPE_DOUBLE, size, numBanks); @@ -71,18 +86,53 @@ public final class DataBufferDouble data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + */ public DataBufferDouble(double[] dataArray, int size) { - super(TYPE_DOUBLE, size); + super(TYPE_DOUBLE, size, 1, 0); + bankData = new double[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + */ public DataBufferDouble(double[] dataArray, int size, int offset) { super(TYPE_DOUBLE, size, 1, offset); + bankData = new double[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferDouble(double[][] dataArray, int size) { super(TYPE_DOUBLE, size, dataArray.length); @@ -90,6 +140,17 @@ public final class DataBufferDouble data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferDouble(double[][] dataArray, int size, int[] offsets) { super(TYPE_DOUBLE, size, dataArray.length, offsets); @@ -97,36 +158,86 @@ public final class DataBufferDouble data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public double[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public double[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public double[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return (int) data[i+offset]; } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { return (int) bankData[bank][i+offsets[bank]]; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { data[i+offset] = (double) val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { bankData[bank][i+offsets[bank]] = (double) val; diff --git a/libjava/java/awt/image/DataBufferFloat.java b/libjava/java/awt/image/DataBufferFloat.java index b2d88c1..9673edd 100644 --- a/libjava/java/awt/image/DataBufferFloat.java +++ b/libjava/java/awt/image/DataBufferFloat.java @@ -56,12 +56,27 @@ public final class DataBufferFloat private float[] data; private float[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>float</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferFloat(int size) { - super(TYPE_FLOAT, size); + super(TYPE_FLOAT, size, 1, 0); + bankData = new float[1][]; data = new float[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>float</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferFloat(int size, int numBanks) { super(TYPE_FLOAT, size, numBanks); @@ -69,18 +84,53 @@ public final class DataBufferFloat data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + */ public DataBufferFloat(float[] dataArray, int size) { - super(TYPE_FLOAT, size); + super(TYPE_FLOAT, size, 1, 0); + bankData = new float[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + */ public DataBufferFloat(float[] dataArray, int size, int offset) { super(TYPE_FLOAT, size, 1, offset); + bankData = new float[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferFloat(float[][] dataArray, int size) { super(TYPE_FLOAT, size, dataArray.length); @@ -88,6 +138,17 @@ public final class DataBufferFloat data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferFloat(float[][] dataArray, int size, int[] offsets) { super(TYPE_FLOAT, size, dataArray.length, offsets); @@ -95,36 +156,86 @@ public final class DataBufferFloat data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public float[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public float[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public float[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return (int) data[i+offset]; } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { return (int) bankData[bank][i+offsets[bank]]; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { data[i+offset] = (float) val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { bankData[bank][i+offsets[bank]] = (float) val; diff --git a/libjava/java/awt/image/DataBufferInt.java b/libjava/java/awt/image/DataBufferInt.java index 54308fe..c5f0853 100644 --- a/libjava/java/awt/image/DataBufferInt.java +++ b/libjava/java/awt/image/DataBufferInt.java @@ -54,12 +54,27 @@ public final class DataBufferInt extends DataBuffer private int[] data; private int[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>int</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferInt(int size) { - super(TYPE_INT, size); + super(TYPE_INT, size, 1, 0); + bankData = new int[1][]; data = new int[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>int</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferInt(int size, int numBanks) { super(TYPE_INT, size, numBanks); @@ -67,18 +82,53 @@ public final class DataBufferInt extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + */ public DataBufferInt(int[] dataArray, int size) { - super(TYPE_INT, size); + super(TYPE_INT, size, 1, 0); + bankData = new int[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + */ public DataBufferInt(int[] dataArray, int size, int offset) { super(TYPE_INT, size, 1, offset); + bankData = new int[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferInt(int[][] dataArray, int size) { super(TYPE_INT, size, dataArray.length); @@ -86,6 +136,17 @@ public final class DataBufferInt extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferInt(int[][] dataArray, int size, int[] offsets) { super(TYPE_INT, size, dataArray.length, offsets); @@ -93,39 +154,88 @@ public final class DataBufferInt extends DataBuffer data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public int[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public int[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public int[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The <code>offset</code> is + * added to the specified index before accessing the underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return data[i+offset]; } + /** + * Returns an element from a particular data bank. The <code>offset</code> + * is added to the specified index before accessing the underlying data + * array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { // get unsigned int as int return bankData[bank][i+offsets[bank]]; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { - data[i+offset] = (int) val; + data[i+offset] = val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { - bankData[bank][i+offsets[bank]] = (int) val; + bankData[bank][i+offsets[bank]] = val; } } diff --git a/libjava/java/awt/image/DataBufferShort.java b/libjava/java/awt/image/DataBufferShort.java index 7a5c394..7a095c4 100644 --- a/libjava/java/awt/image/DataBufferShort.java +++ b/libjava/java/awt/image/DataBufferShort.java @@ -1,4 +1,5 @@ -/* Copyright (C) 2004 Free Software Foundation +/* DataBufferShort.java -- + Copyright (C) 2004 Free Software Foundation This file is part of GNU Classpath. @@ -54,12 +55,27 @@ public final class DataBufferShort extends DataBuffer private short[] data; private short[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>short</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferShort(int size) { - super(TYPE_SHORT, size); + super(TYPE_SHORT, size, 1, 0); + bankData = new short[1][]; data = new short[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>short</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferShort(int size, int numBanks) { super(TYPE_SHORT, size, numBanks); @@ -67,18 +83,53 @@ public final class DataBufferShort extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + */ public DataBufferShort(short[] dataArray, int size) { - super(TYPE_SHORT, size); + super(TYPE_SHORT, size, 1, 0); + bankData = new short[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * <p> + * Note: there is no exception when <code>dataArray</code> is + * <code>null</code>, but in that case an exception will be thrown + * later if you attempt to access the data buffer. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + */ public DataBufferShort(short[] dataArray, int size, int offset) { super(TYPE_SHORT, size, 1, offset); + bankData = new short[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferShort(short[][] dataArray, int size) { super(TYPE_SHORT, size, dataArray.length); @@ -86,6 +137,17 @@ public final class DataBufferShort extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferShort(short[][] dataArray, int size, int[] offsets) { super(TYPE_SHORT, size, dataArray.length, offsets); @@ -93,36 +155,86 @@ public final class DataBufferShort extends DataBuffer data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public short[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public short[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public short[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return data[i+offset]; } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { return bankData[bank][i+offsets[bank]]; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { data[i+offset] = (short) val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { bankData[bank][i+offsets[bank]] = (short) val; diff --git a/libjava/java/awt/image/DataBufferUShort.java b/libjava/java/awt/image/DataBufferUShort.java index e11b4ab..6efe73d 100644 --- a/libjava/java/awt/image/DataBufferUShort.java +++ b/libjava/java/awt/image/DataBufferUShort.java @@ -1,4 +1,5 @@ -/* Copyright (C) 2000, 2002 Free Software Foundation +/* DataBufferUShort.java -- + Copyright (C) 2000, 2002, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -54,12 +55,27 @@ public final class DataBufferUShort extends DataBuffer private short[] data; private short[][] bankData; + /** + * Creates a new data buffer with a single data bank containing the + * specified number of <code>short</code> elements. + * + * @param size the number of elements in the data bank. + */ public DataBufferUShort(int size) { - super(TYPE_USHORT, size); + super(TYPE_USHORT, size, 1, 0); + bankData = new short[1][]; data = new short[size]; + bankData[0] = data; } + /** + * Creates a new data buffer with the specified number of data banks, + * each containing the specified number of <code>short</code> elements. + * + * @param size the number of elements in the data bank. + * @param numBanks the number of data banks. + */ public DataBufferUShort(int size, int numBanks) { super(TYPE_USHORT, size, numBanks); @@ -67,18 +83,53 @@ public final class DataBufferUShort extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data bank. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if dataArray is null + */ public DataBufferUShort(short[] dataArray, int size) { - super(TYPE_USHORT, size); + super(TYPE_USHORT, size, 1, 0); + if (dataArray == null) + throw new NullPointerException(); + bankData = new short[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data bank, with + * the specified offset to the first element. + * + * @param dataArray the data bank. + * @param size the number of elements in the data bank. + * @param offset the offset to the first element in the array. + * + * @throws NullPointerException if dataArray is null + */ public DataBufferUShort(short[] dataArray, int size, int offset) { super(TYPE_USHORT, size, 1, offset); + if (dataArray == null) + throw new NullPointerException(); + bankData = new short[1][]; data = dataArray; + bankData[0] = data; } + /** + * Creates a new data buffer backed by the specified data banks. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferUShort(short[][] dataArray, int size) { super(TYPE_USHORT, size, dataArray.length); @@ -86,6 +137,17 @@ public final class DataBufferUShort extends DataBuffer data = bankData[0]; } + /** + * Creates a new data buffer backed by the specified data banks, with + * the specified offsets to the first element in each bank. + * + * @param dataArray the data banks. + * @param size the number of elements in the data bank. + * @param offsets the offsets to the first element in each data bank. + * + * @throws NullPointerException if <code>dataArray</code> is + * <code>null</code>. + */ public DataBufferUShort(short[][] dataArray, int size, int[] offsets) { super(TYPE_USHORT, size, dataArray.length, offsets); @@ -93,37 +155,87 @@ public final class DataBufferUShort extends DataBuffer data = bankData[0]; } + /** + * Returns the first data bank. + * + * @return The first data bank. + */ public short[] getData() { return data; } + /** + * Returns a data bank. + * + * @param bank the bank index. + * @return A data bank. + */ public short[] getData(int bank) { return bankData[bank]; } + /** + * Returns the array underlying this <code>DataBuffer</code>. + * + * @return The data banks. + */ public short[][] getBankData() { return bankData; } + /** + * Returns an element from the first data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param i the element index. + * @return The element. + */ public int getElem(int i) { return data[i+offset] & 0xffff; // get unsigned short as int } + /** + * Returns an element from a particular data bank. The offset (specified in + * the constructor) is added to <code>i</code> before accessing the + * underlying data array. + * + * @param bank the bank index. + * @param i the element index. + * @return The element. + */ public int getElem(int bank, int i) { // get unsigned short as int return bankData[bank][i+offsets[bank]] & 0xffff; } + /** + * Sets an element in the first data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param i the element index. + * @param val the new element value. + */ public void setElem(int i, int val) { data[i+offset] = (short) val; } + /** + * Sets an element in a particular data bank. The offset (specified in the + * constructor) is added to <code>i</code> before updating the underlying + * data array. + * + * @param bank the data bank index. + * @param i the element index. + * @param val the new element value. + */ public void setElem(int bank, int i, int val) { bankData[bank][i+offsets[bank]] = (short) val; diff --git a/libjava/java/awt/image/DirectColorModel.java b/libjava/java/awt/image/DirectColorModel.java index 3ac43cf..b1aa6c0 100644 --- a/libjava/java/awt/image/DirectColorModel.java +++ b/libjava/java/awt/image/DirectColorModel.java @@ -1,4 +1,5 @@ -/* Copyright (C) 1999, 2000, 2002 Free Software Foundation +/* DirectColorModel.java -- + Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -37,13 +38,14 @@ exception statement from your version. */ package java.awt.image; +import gnu.java.awt.Buffers; + import java.awt.Point; import java.awt.Transparency; import java.awt.color.ColorSpace; -import gnu.java.awt.Buffers; /** - * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> + * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) * @author C. Brian Jones (cbj@gnu.org) * @author Mark Benvenuto (mcb54@columbia.edu) */ @@ -56,7 +58,7 @@ public class DirectColorModel extends PackedColorModel * most likely order of alpha, red, green, blue from the most significant * byte to the least significant byte. * - * @param bits the number of bits wide used for bit size of pixel values + * @param pixelBits the number of bits wide used for bit size of pixel values * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel * @param bmask the bits describing the blue component of a pixel @@ -77,7 +79,7 @@ public class DirectColorModel extends PackedColorModel * most likely order of red, green, blue from the most significant * byte to the least significant byte. * - * @param bits the number of bits wide used for bit size of pixel values + * @param pixelBits the number of bits wide used for bit size of pixel values * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel * @param bmask the bits describing the blue component of a pixel @@ -162,7 +164,7 @@ public class DirectColorModel extends PackedColorModel return extractAndScaleSample(pixel, 3); } - private final int extractAndNormalizeSample(int pixel, int component) + private int extractAndNormalizeSample(int pixel, int component) { int value = extractAndScaleSample(pixel, component); if (hasAlpha() && isAlphaPremultiplied()) @@ -170,7 +172,7 @@ public class DirectColorModel extends PackedColorModel return value; } - private final int extractAndScaleSample(int pixel, int component) + private int extractAndScaleSample(int pixel, int component) { int field = pixel & getMask(component); int to8BitShift = @@ -303,7 +305,7 @@ public class DirectColorModel extends PackedColorModel * @param highBit the position of the most significant bit in the * val parameter. */ - private final int valueToField(int val, int component, int highBit) + private int valueToField(int val, int component, int highBit) { int toFieldShift = getComponentSize(component) + shifts[component] - highBit; @@ -317,7 +319,7 @@ public class DirectColorModel extends PackedColorModel * Converts a 16 bit value to the correct field bits based on the * information derived from the field masks. */ - private final int value16ToField(int val, int component) + private int value16ToField(int val, int component) { int toFieldShift = getComponentSize(component) + shifts[component] - 16; return (toFieldShift>0) ? diff --git a/libjava/java/awt/image/IndexColorModel.java b/libjava/java/awt/image/IndexColorModel.java index 9ceb0bf..6791589 100644 --- a/libjava/java/awt/image/IndexColorModel.java +++ b/libjava/java/awt/image/IndexColorModel.java @@ -38,7 +38,29 @@ exception statement from your version. */ package java.awt.image; +import java.awt.color.ColorSpace; +import java.math.BigInteger; + /** + * Color model similar to pseudo visual in X11. + * + * This color model maps linear pixel values to actual RGB and alpha colors. + * Thus, pixel values are indexes into the color map. Each color component is + * an 8-bit unsigned value. + * + * The IndexColorModel supports a map of valid pixels, allowing the + * representation of holes in the the color map. The valid map is represented + * as a BigInteger where each bit indicates the validity of the map entry with + * the same index. + * + * Colors can have alpha components for transparency support. If alpha + * component values aren't given, color values are opaque. The model also + * supports a reserved pixel value to represent completely transparent colors, + * no matter what the actual color component values are. + * + * IndexColorModel supports anywhere from 1 to 16 bit index values. The + * allowed transfer types are DataBuffer.TYPE_BYTE and DataBuffer.TYPE_USHORT. + * * @author C. Brian Jones (cbj@gnu.org) */ public class IndexColorModel extends ColorModel @@ -47,6 +69,7 @@ public class IndexColorModel extends ColorModel private boolean opaque; private int trans = -1; private int[] rgb; + private BigInteger validBits = BigInteger.ZERO; /** * Each array much contain <code>size</code> elements. For each @@ -127,6 +150,9 @@ public class IndexColorModel extends ColorModel | (blues[i] & 0xff)); } } + + // Generate a bigint with 1's for every pixel + validBits = validBits.setBit(size).subtract(BigInteger.ONE); } /** @@ -140,6 +166,7 @@ public class IndexColorModel extends ColorModel * @param cmap packed color components * @param start the offset of the first color component in <code>cmap</code> * @param hasAlpha <code>cmap</code> has alpha values + * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1. */ public IndexColorModel (int bits, int size, byte[] cmap, int start, boolean hasAlpha) @@ -148,25 +175,155 @@ public class IndexColorModel extends ColorModel } /** - * Each array much contain <code>size</code> elements. For each - * array, the i-th color is described by reds[i], greens[i], - * blues[i], alphas[i], unless alphas is not specified, then all the - * colors are opaque except for the transparent color. - * + * Construct an IndexColorModel from an array of red, green, blue, and + * optional alpha components. The component values are interleaved as RGB(A). + * * @param bits the number of bits needed to represent <code>size</code> colors * @param size the number of colors in the color map - * @param cmap packed color components + * @param cmap interleaved color components * @param start the offset of the first color component in <code>cmap</code> * @param hasAlpha <code>cmap</code> has alpha values * @param trans the index of the transparent color + * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1. */ public IndexColorModel (int bits, int size, byte[] cmap, int start, boolean hasAlpha, int trans) { super (bits); + if (bits > 16) + throw new IllegalArgumentException("bits > 16"); + if (size < 1) + throw new IllegalArgumentException("size < 1"); + map_size = size; + opaque = !hasAlpha; + this.trans = trans; + + rgb = new int[size]; + if (hasAlpha) + { + for (int i = 0; i < size; i++) + rgb[i] = + // alpha + ((cmap[4 * i + 3 + start] & 0xff) << 24 + // red + | ((cmap[4 * i + start] & 0xff) << 16) + // green + | ((cmap[4 * i + 1 + start] & 0xff) << 8) + // blue + | (cmap[4 * i + 2 + start] & 0xff)); + } + else + { + for (int i = 0; i < size; i++) + rgb[i] = (0xff000000 + // red + | ((cmap[3 * i + start] & 0xff) << 16) + // green + | ((cmap[3 * i + 1 + start] & 0xff) << 8) + // blue + | (cmap[3 * i + 2 + start] & 0xff)); + } + + // Generate a bigint with 1's for every pixel + validBits = validBits.setBit(size).subtract(BigInteger.ONE); + } + + /** + * Construct an IndexColorModel from an array of <code>size</code> packed + * colors. Each int element contains 8-bit red, green, blue, and optional + * alpha values packed in order. If hasAlpha is false, then all the colors + * are opaque except for the transparent color. + * + * @param bits the number of bits needed to represent <code>size</code> colors + * @param size the number of colors in the color map + * @param cmap packed color components + * @param start the offset of the first color component in <code>cmap</code> + * @param hasAlpha <code>cmap</code> has alpha values + * @param trans the index of the transparent color + * @param transferType DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT + * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1. + * @throws IllegalArgumentException if transferType is something other than + * TYPE_BYTE or TYPE_USHORT. + */ + public IndexColorModel (int bits, int size, int[] cmap, int start, + boolean hasAlpha, int trans, int transferType) + { + super(bits * 4, // total bits, sRGB, four channels + nArray(bits, 4), // bits for each channel + ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB + true, // has alpha + false, // not premultiplied + TRANSLUCENT, transferType); + if (transferType != DataBuffer.TYPE_BYTE + && transferType != DataBuffer.TYPE_USHORT) + throw new IllegalArgumentException(); + if (bits > 16) + throw new IllegalArgumentException("bits > 16"); + if (size < 1) + throw new IllegalArgumentException("size < 1"); map_size = size; opaque = !hasAlpha; this.trans = trans; + + rgb = new int[size]; + if (!hasAlpha) + for (int i = 0; i < size; i++) + rgb[i] = cmap[i + start] | 0xff000000; + else + System.arraycopy(cmap, start, rgb, 0, size); + + // Generate a bigint with 1's for every pixel + validBits = validBits.setBit(size).subtract(BigInteger.ONE); + } + + /** + * Construct an IndexColorModel using a colormap with holes. + * + * The IndexColorModel is built from the array of ints defining the + * colormap. Each element contains red, green, blue, and alpha + * components. The ColorSpace is sRGB. The transparency value is + * automatically determined. + * + * This constructor permits indicating which colormap entries are valid, + * using the validBits argument. Each entry in cmap is valid if the + * corresponding bit in validBits is set. + * + * @param bits the number of bits needed to represent <code>size</code> colors + * @param size the number of colors in the color map + * @param cmap packed color components + * @param start the offset of the first color component in <code>cmap</code> + * @param transferType DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT + * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1. + * @throws IllegalArgumentException if transferType is something other than + * TYPE_BYTE or TYPE_USHORT. + */ + public IndexColorModel (int bits, int size, int[] cmap, int start, + int transferType, BigInteger validBits) + { + super(bits * 4, // total bits, sRGB, four channels + nArray(bits, 4), // bits for each channel + ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB + true, // has alpha + false, // not premultiplied + TRANSLUCENT, transferType); + if (transferType != DataBuffer.TYPE_BYTE + && transferType != DataBuffer.TYPE_USHORT) + throw new IllegalArgumentException(); + if (bits > 16) + throw new IllegalArgumentException("bits > 16"); + if (size < 1) + throw new IllegalArgumentException("size < 1"); + map_size = size; + opaque = false; + this.trans = -1; + this.validBits = validBits; + + rgb = new int[size]; + if (!hasAlpha) + for (int i = 0; i < size; i++) + rgb[i] = cmap[i + start] | 0xff000000; + else + System.arraycopy(cmap, start, rgb, 0, size); } public final int getMapSize () @@ -279,11 +436,79 @@ public class IndexColorModel extends ColorModel return 0; } - //pixel_bits is number of bits to be in generated mask + /** + * Get the RGB color values of all pixels in the map using the default + * RGB color model. + * + * @param rgb The destination array. + */ + public final void getRGBs (int[] rgb) + { + System.arraycopy(this.rgb, 0, rgb, 0, map_size); + } + + //pixel_bits is number of bits to be in generated mask private int generateMask (int offset) { return (((2 << pixel_bits ) - 1) << (pixel_bits * offset)); } + /** Return true if pixel is valid, false otherwise. */ + public boolean isValid(int pixel) + { + return validBits.testBit(pixel); + } + + /** Return true if all pixels are valid, false otherwise. */ + public boolean isValid() + { + // Generate a bigint with 1's for every pixel + BigInteger allbits = new BigInteger("0"); + allbits.setBit(map_size); + allbits.subtract(new BigInteger("1")); + return allbits.equals(validBits); + } + + /** + * Returns a BigInteger where each bit represents an entry in the color + * model. If the bit is on, the entry is valid. + */ + public BigInteger getValidPixels() + { + return validBits; + } + + /** + * Construct a BufferedImage with rgb pixel values from a Raster. + * + * Constructs a new BufferedImage in which each pixel is an RGBA int from + * a Raster with index-valued pixels. If this model has no alpha component + * or transparent pixel, the type of the new BufferedImage is TYPE_INT_RGB. + * Otherwise the type is TYPE_INT_ARGB. If forceARGB is true, the type is + * forced to be TYPE_INT_ARGB no matter what. + * + * @param raster The source of pixel values. + * @param forceARGB True if type must be TYPE_INT_ARGB. + * @return New BufferedImage with RBGA int pixel values. + */ + public BufferedImage convertToIntDiscrete(Raster raster, boolean forceARGB) + { + int type = forceARGB ? BufferedImage.TYPE_INT_ARGB + : ((opaque && trans == -1) ? BufferedImage.TYPE_INT_RGB : + BufferedImage.TYPE_INT_ARGB); + + // FIXME: assuming that raster has only 1 band since pixels are supposed + // to be int indexes. + // FIXME: it would likely be more efficient to fetch a complete array, + // but it would take much more memory. + // FIXME: I'm not sure if transparent pixels or alpha values need special + // handling here. + BufferedImage im = new BufferedImage(raster.width, raster.height, type); + for (int x = raster.minX; x < raster.width + raster.minX; x++) + for (int y = raster.minY; y < raster.height + raster.minY; y++) + im.setRGB(x, y, rgb[raster.getSample(x, y, 0)]); + + return im; + } } diff --git a/libjava/java/awt/image/LookupOp.java b/libjava/java/awt/image/LookupOp.java new file mode 100644 index 0000000..523aba4 --- /dev/null +++ b/libjava/java/awt/image/LookupOp.java @@ -0,0 +1,252 @@ +/* LookupOp.java -- Filter that converts each pixel using a lookup table. + Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.awt.image; + +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +/** + * LookupOp is a filter that converts each pixel using a lookup table. + * + * For filtering Rasters, the lookup table must have either one component + * that is applied to all bands, or one component for every band in the + * Rasters. + * + * For BufferedImages, the lookup table may apply to both color and alpha + * components. If the lookup table contains one component, or if there are + * the same number of components as color components in the source, the table + * applies to all color components. Otherwise the table applies to all + * components including alpha. Alpha premultiplication is ignored during the + * lookup filtering. + * + * After filtering, if color conversion is necessary, the conversion happens, + * taking alpha premultiplication into account. + * + * @author jlquinn + */ +public class LookupOp implements BufferedImageOp, RasterOp +{ + private LookupTable lut; + private RenderingHints hints; + + /** Construct a new LookupOp. + * + * @param lookup LookupTable to use. + * @param hints Rendering hints (can be null). + */ + public LookupOp(LookupTable lookup, RenderingHints hints) + { + lut = lookup; + this.hints = hints; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) + */ + public BufferedImage filter(BufferedImage src, BufferedImage dst) + { + if (src.getColorModel() instanceof IndexColorModel) + throw new IllegalArgumentException("LookupOp.filter: IndexColorModel " + + "not allowed"); + if (dst == null) + dst = createCompatibleDestImage(src, src.getColorModel()); + + // Set up for potential colormodel mismatch + BufferedImage tgt; + if (dst.getColorModel().equals(src.getColorModel())) + tgt = dst; + else + tgt = createCompatibleDestImage(src, src.getColorModel()); + + Raster sr = src.getRaster(); + WritableRaster dr = tgt.getRaster(); + + if (src.getColorModel().hasAlpha() && + (lut.getNumComponents() == 1 || + lut.getNumComponents() == src.getColorModel().getNumColorComponents())) + { + // Need to ignore alpha for lookup + int[] dbuf = new int[src.getColorModel().getNumComponents()]; + int tmpBands = src.getColorModel().getNumColorComponents(); + int[] tmp = new int[tmpBands]; + + // Filter the pixels + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + { + // Filter only color components, but also copy alpha + sr.getPixel(x, y, dbuf); + System.arraycopy(dbuf, 0, tmp, 0, tmpBands); + dr.setPixel(x, y, lut.lookupPixel(tmp, dbuf)); + } + } + else if (lut.getNumComponents() != 1 + && + lut.getNumComponents() != src.getColorModel().getNumComponents()) + throw new IllegalArgumentException("LookupOp.filter: " + + "Incompatible lookup " + + "table and source image"); + + // No alpha to ignore + int[] dbuf = new int[src.getColorModel().getNumComponents()]; + + // Filter the pixels + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + dr.setPixel(x, y, lut.lookupPixel(sr.getPixel(x, y, dbuf), dbuf)); + + if (tgt != dst) + { + // Convert between color models. + // TODO Check that premultiplied alpha is handled correctly here. + Graphics2D gg = dst.createGraphics(); + gg.setRenderingHints(hints); + gg.drawImage(tgt, 0, 0, null); + gg.dispose(); + } + + return dst; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage) + */ + public Rectangle2D getBounds2D(BufferedImage src) + { + return src.getRaster().getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) + */ + public BufferedImage createCompatibleDestImage(BufferedImage src, + ColorModel dstCM) + { + // FIXME: set properties to those in src + return new BufferedImage(dstCM, + src.getRaster().createCompatibleWritableRaster(), + src.isPremultiplied, null); + } + + /** Return corresponding destination point for source point. + * + * LookupOp will return the value of src unchanged. + * @param src The source point. + * @param dst The destination point. + * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) + */ + public Point2D getPoint2D(Point2D src, Point2D dst) + { + if (dst == null) + return (Point2D) src.clone(); + + dst.setLocation(src); + return dst; + } + + /** Return the LookupTable for this op. */ + public LookupTable getTable() + { + return lut; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getRenderingHints() + */ + public RenderingHints getRenderingHints() + { + return hints; + } + + /** Filter a raster through a lookup table. + * + * Applies the lookup table for this Rasterop to each pixel of src and + * puts the results in dest. If dest is null, a new Raster is created and + * returned. + * + * @param src The source raster. + * @param dest The destination raster. + * @return The WritableRaster with the filtered pixels. + * @throws IllegalArgumentException if lookup table has more than one + * component but not the same as src and dest. + * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster) + */ + public WritableRaster filter(Raster src, WritableRaster dest) + { + if (dest == null) + // Allocate a raster if needed + dest = createCompatibleDestRaster(src); + else + if (src.getNumBands() != dest.getNumBands()) + throw new IllegalArgumentException(); + + if (lut.getNumComponents() != 1 + && lut.getNumComponents() != src.getNumBands()) + throw new IllegalArgumentException(); + + + // Allocate pixel storage. + int[] tmp = new int[src.getNumBands()]; + + // Filter the pixels + for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++) + for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++) + dest.setPixel(x, y, lut.lookupPixel(src.getPixel(x, y, tmp), tmp)); + return dest; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster) + */ + public Rectangle2D getBounds2D(Raster src) + { + return src.getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) + */ + public WritableRaster createCompatibleDestRaster(Raster src) + { + return src.createCompatibleWritableRaster(); + } + +} diff --git a/libjava/java/awt/image/MemoryImageSource.java b/libjava/java/awt/image/MemoryImageSource.java index ddd5800..07e42cf 100644 --- a/libjava/java/awt/image/MemoryImageSource.java +++ b/libjava/java/awt/image/MemoryImageSource.java @@ -1,5 +1,5 @@ /* MemoryImageSource.java -- Java class for providing image data - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,8 +38,6 @@ exception statement from your version. */ package java.awt.image; -import java.awt.Image; -import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; @@ -54,8 +52,16 @@ public class MemoryImageSource implements ImageProducer private Vector consumers = new Vector(); /** - Constructs an ImageProducer from memory - */ + * Construct an image producer that reads image data from a byte + * array. + * + * @param w width of image + * @param h height of image + * @param cm the color model used to represent pixel values + * @param pix a byte array of pixel values + * @param off the offset into the array at which the first pixel is stored + * @param scan the number of array elements that represents a single pixel row + */ public MemoryImageSource(int w, int h, ColorModel cm, byte pix[], int off, int scan) { @@ -75,12 +81,19 @@ public class MemoryImageSource implements ImageProducer scansize = scan; this.props = props; int max = (( scansize > width ) ? scansize : width ); - pixelb = new byte[ max * height ]; - System.arraycopy( pix, 0, pixelb, 0, max * height ); + pixelb = pix; } /** - Constructs an ImageProducer from memory - */ + * Construct an image producer that reads image data from an + * integer array. + * + * @param w width of image + * @param h height of image + * @param cm the color model used to represent pixel values + * @param pix an integer array of pixel values + * @param off the offset into the array at which the first pixel is stored + * @param scan the number of array elements that represents a single pixel row + */ public MemoryImageSource(int w, int h, ColorModel cm, int pix[], int off, int scan) { @@ -101,8 +114,7 @@ public class MemoryImageSource implements ImageProducer scansize = scan; this.props = props; int max = (( scansize > width ) ? scansize : width ); - pixeli = new int[ max * height ]; - System.arraycopy( pix, 0, pixeli, 0, max * height ); + pixeli = pix; } /** Constructs an ImageProducer from memory using the default RGB ColorModel @@ -166,9 +178,12 @@ public class MemoryImageSource implements ImageProducer Vector list = (Vector) consumers.clone(); for(int i = 0; i < list.size(); i++) { ic = (ImageConsumer) list.elementAt(i); - sendPicture( ic ); - ic.imageComplete( ImageConsumer.STATICIMAGEDONE ); - } + sendPicture( ic ); + if (animated) + ic.imageComplete( ImageConsumer.SINGLEFRAME ); + else + ic.imageComplete( ImageConsumer.STATICIMAGEDONE ); + } } /** @@ -261,13 +276,14 @@ public class MemoryImageSource implements ImageProducer } if( pixeli != null ) { int[] pixelbuf = new int[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } else { byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, 0, w * h); + ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } ic.imageComplete( ImageConsumer.SINGLEFRAME ); @@ -306,13 +322,13 @@ public class MemoryImageSource implements ImageProducer } if( pixeli != null ) { int[] pixelbuf = new int[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } else { byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } if( framenotify == true ) diff --git a/libjava/java/awt/image/MultiPixelPackedSampleModel.java b/libjava/java/awt/image/MultiPixelPackedSampleModel.java new file mode 100644 index 0000000..0525d37 --- /dev/null +++ b/libjava/java/awt/image/MultiPixelPackedSampleModel.java @@ -0,0 +1,387 @@ +/* Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.awt.image; + +import gnu.java.awt.Buffers; + +/** + * MultiPixelPackedSampleModel provides a single band model that supports + * multiple pixels in a single unit. Pixels have 2^n bits and 2^k pixels fit + * per data element. + * + * @author Jerry Quinn <jlquinn@optonline.net> + */ +public class MultiPixelPackedSampleModel extends SampleModel +{ + private int scanlineStride; + private int[] bitMasks; + private int[] bitOffsets; + private int[] sampleSize; + private int dataBitOffset; + private int elemBits; + private int numberOfBits; + private int numElems; + + public MultiPixelPackedSampleModel(int dataType, int w, int h, + int numberOfBits) + { + this(dataType, w, h, 0, numberOfBits, 0); + } + + public MultiPixelPackedSampleModel(int dataType, int w, int h, + int numberOfBits, int scanlineStride, + int dataBitOffset) + { + super(dataType, w, h, 1); + + switch (dataType) + { + case DataBuffer.TYPE_BYTE: + elemBits = 8; + break; + case DataBuffer.TYPE_USHORT: + elemBits = 16; + break; + case DataBuffer.TYPE_INT: + elemBits = 32; + break; + default: + throw new IllegalArgumentException("MultiPixelPackedSampleModel" + + " unsupported dataType"); + } + + this.dataBitOffset = dataBitOffset; + + this.numberOfBits = numberOfBits; + if (numberOfBits > elemBits) + throw new RasterFormatException("MultiPixelPackedSampleModel pixel size" + + " larger than dataType"); + switch (numberOfBits) + { + case 1: case 2: case 4: case 8: case 16: case 32: break; + default: + throw new RasterFormatException("MultiPixelPackedSampleModel pixel" + + " size not 2^n bits"); + } + numElems = elemBits / numberOfBits; + + // Compute scan line large enough for w pixels. + if (scanlineStride == 0) + scanlineStride = ((dataBitOffset + w * numberOfBits) / elemBits) + 1; + this.scanlineStride = scanlineStride; + + + sampleSize = new int[1]; + sampleSize[0] = numberOfBits; + + bitMasks = new int[numElems]; + bitOffsets = new int[numElems]; + for (int i=0; i < numElems; i++) + { + bitOffsets[i] = numberOfBits * i; + bitMasks[i] = ((1 << numberOfBits) - 1) << bitOffsets[i]; + } + } + + public SampleModel createCompatibleSampleModel(int w, int h) + { + /* FIXME: We can avoid recalculation of bit offsets and sample + sizes here by passing these from the current instance to a + special private constructor. */ + return new MultiPixelPackedSampleModel(dataType, w, h, numberOfBits); + } + + + /** + * Creates a DataBuffer for holding pixel data in the format and + * layout described by this SampleModel. The returned buffer will + * consist of one single bank. + */ + public DataBuffer createDataBuffer() + { + int size; + + // FIXME: The comment refers to SinglePixelPackedSampleModel. See if the + // same can be done for MultiPixelPackedSampleModel. + // We can save (scanlineStride - width) pixels at the very end of + // the buffer. The Sun reference implementation (J2SE 1.3.1 and + // 1.4.1_01) seems to do this; tested with Mauve test code. + size = scanlineStride * height; + + return Buffers.createBuffer(getDataType(), size); + } + + + public int getNumDataElements() + { + return 1; + } + + public int[] getSampleSize() + { + return sampleSize; + } + + public int getSampleSize(int band) + { + return sampleSize[0]; + } + + public int getOffset(int x, int y) + { + return scanlineStride * y + ((dataBitOffset + x*numberOfBits) / elemBits); + } + + public int getBitOffset(int x) + { + return (dataBitOffset + x*numberOfBits) % elemBits; + } + + public int getDataBitOffset() + { + return dataBitOffset; + } + + public int getScanlineStride() + { + return scanlineStride; + } + + public int getPixelBitStride() + { + return numberOfBits; + } + + + public SampleModel createSubsetSampleModel(int[] bands) + { + int numBands = bands.length; + if (numBands != 1) + throw new RasterFormatException("MultiPixelPackedSampleModel only" + + " supports one band"); + + return new MultiPixelPackedSampleModel(dataType, width, height, + numberOfBits, scanlineStride, + dataBitOffset); + } + + /** + * Extract one pixel and return in an array of transfer type. + * + * Extracts the pixel at x, y from data and stores into the 0th index of the + * array obj, since there is only one band. If obj is null, a new array of + * getTransferType() is created. + * + * @param x The x-coordinate of the pixel rectangle to store in <code>obj</code>. + * @param y The y-coordinate of the pixel rectangle to store in <code>obj</code>. + * @param obj The primitive array to store the pixels into or null to force creation. + * @param data The DataBuffer that is the source of the pixel data. + * @return The primitive array containing the pixel data. + * @see java.awt.image.SampleModel#getDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer) + */ + public Object getDataElements(int x, int y, Object obj, + DataBuffer data) + { + int pixel = getSample(x, y, 0, data); + switch (getTransferType()) + { + case DataBuffer.TYPE_BYTE: + if (obj == null) obj = new byte[1]; + ((byte[])obj)[0] = (byte)pixel; + return obj; + case DataBuffer.TYPE_USHORT: + if (obj == null) obj = new short[1]; + ((short[])obj)[0] = (short)pixel; + return obj; + case DataBuffer.TYPE_INT: + if (obj == null) obj = new int[1]; + ((int[])obj)[0] = pixel; + return obj; + default: + // Seems like the only sensible thing to do. + throw new ClassCastException(); + } + } + + public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) + { + if (iArray == null) iArray = new int[1]; + iArray[0] = getSample(x, y, 0, data); + + return iArray; + } + + public int[] getPixels(int x, int y, int w, int h, int[] iArray, + DataBuffer data) + { + int offset = getOffset(x, y); + if (iArray == null) iArray = new int[w*h]; + int outOffset = 0; + for (y=0; y<h; y++) + { + int lineOffset = offset; + for (x=0; x<w;) + { + int samples = data.getElem(lineOffset++); + for (int b=0; b<numElems && x<w; b++) + { + iArray[outOffset++] = (samples & bitMasks[b]) >>> bitOffsets[b]; + x++; + } + } + offset += scanlineStride; + } + return iArray; + } + + public int getSample(int x, int y, int b, DataBuffer data) + { + int pos = + ((dataBitOffset + x * numberOfBits) % elemBits) / numberOfBits; + int offset = getOffset(x, y); + int samples = data.getElem(offset); + return (samples & bitMasks[pos]) >>> bitOffsets[pos]; + } + + /** + * Set the pixel at x, y to the value in the first element of the primitive + * array obj. + * + * @param x The x-coordinate of the data elements in <code>obj</code>. + * @param y The y-coordinate of the data elements in <code>obj</code>. + * @param obj The primitive array containing the data elements to set. + * @param data The DataBuffer to store the data elements into. + * @see java.awt.image.SampleModel#setDataElements(int, int, int, int, java.lang.Object, java.awt.image.DataBuffer) + */ + public void setDataElements(int x, int y, Object obj, DataBuffer data) + { + int transferType = getTransferType(); + if (getTransferType() != data.getDataType()) + { + throw new IllegalArgumentException("transfer type ("+ + getTransferType()+"), "+ + "does not match data "+ + "buffer type (" + + data.getDataType() + + ")."); + } + + int offset = getOffset(x, y); + + try + { + switch (transferType) + { + case DataBuffer.TYPE_BYTE: + { + DataBufferByte out = (DataBufferByte) data; + byte[] in = (byte[]) obj; + out.getData()[offset] = in[0]; + return; + } + case DataBuffer.TYPE_USHORT: + { + DataBufferUShort out = (DataBufferUShort) data; + short[] in = (short[]) obj; + out.getData()[offset] = in[0]; + return; + } + case DataBuffer.TYPE_INT: + { + DataBufferInt out = (DataBufferInt) data; + int[] in = (int[]) obj; + out.getData()[offset] = in[0]; + return; + } + default: + throw new ClassCastException("Unsupported data type"); + } + } + catch (ArrayIndexOutOfBoundsException aioobe) + { + String msg = "While writing data elements" + + ", x="+x+", y="+y+ + ", width="+width+", height="+height+ + ", scanlineStride="+scanlineStride+ + ", offset="+offset+ + ", data.getSize()="+data.getSize()+ + ", data.getOffset()="+data.getOffset()+ + ": " + + aioobe; + throw new ArrayIndexOutOfBoundsException(msg); + } + } + + public void setPixel(int x, int y, int[] iArray, DataBuffer data) + { + setSample(x, y, 0, iArray[0], data); + } + + public void setSample(int x, int y, int b, int s, DataBuffer data) + { + int bitpos = + ((dataBitOffset + x * numberOfBits) % elemBits) / numberOfBits; + int offset = getOffset(x, y); + + s = s << bitOffsets[bitpos]; + s = s & bitMasks[bitpos]; + + int sample = data.getElem(offset); + sample |= s; + data.setElem(offset, sample); + } + + /** + * Creates a String with some information about this SampleModel. + * @return A String describing this SampleModel. + * @see java.lang.Object#toString() + */ + public String toString() + { + StringBuffer result = new StringBuffer(); + result.append(getClass().getName()); + result.append("["); + result.append("scanlineStride=").append(scanlineStride); + for(int i=0; i < bitMasks.length; i+=1) + { + result.append(", mask[").append(i).append("]=0x").append(Integer.toHexString(bitMasks[i])); + } + + result.append("]"); + return result.toString(); + } +} diff --git a/libjava/java/awt/image/PackedColorModel.java b/libjava/java/awt/image/PackedColorModel.java index 2d8b0e1..1f18cf6 100644 --- a/libjava/java/awt/image/PackedColorModel.java +++ b/libjava/java/awt/image/PackedColorModel.java @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002 Free Software Foundation +/* Copyright (C) 2000, 2002, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -34,11 +34,13 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ + package java.awt.image; +import gnu.java.awt.BitMaskExtent; + import java.awt.Point; import java.awt.color.ColorSpace; -import gnu.java.awt.BitMaskExtent; /** * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> diff --git a/libjava/java/awt/image/PixelGrabber.java b/libjava/java/awt/image/PixelGrabber.java index d6d2403..bcfa050 100644 --- a/libjava/java/awt/image/PixelGrabber.java +++ b/libjava/java/awt/image/PixelGrabber.java @@ -1,39 +1,39 @@ /* PixelGrabber.java -- retrieve a subset of an image's data - Copyright (C) 1999, 2003 Free Software Foundation, Inc. - - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. */ + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ package java.awt.image; diff --git a/libjava/java/awt/image/RGBImageFilter.java b/libjava/java/awt/image/RGBImageFilter.java index 819580e..0fd977e 100644 --- a/libjava/java/awt/image/RGBImageFilter.java +++ b/libjava/java/awt/image/RGBImageFilter.java @@ -140,28 +140,19 @@ public abstract class RGBImageFilter extends ImageFilter @param y the y coordinate of the rectangle @param w the width of the rectangle @param h the height of the rectangle - @param model the <code>ColorModel</code> used to translate the pixels @param pixels the array of pixel values @param offset the index of the first pixels in the <code>pixels</code> array @param scansize the width to use in extracting pixels from the <code>pixels</code> array */ - public void filterRGBPixels(int x, - int y, - int w, - int h, - int[] pixels, - int off, - int scansize) + public void filterRGBPixels(int x, int y, int w, int h, int[] pixels, + int offset, int scansize) { - int xp, yp, i; - - i = 0; - for( xp = x; xp < ( x + w); xp++ ) - for( yp = y; yp < (y + h); yp++ ) - { - pixels[i] = filterRGB( xp, yp, pixels[i] ); - i++; - } + for (int xp = x; xp < (x + w); xp++) + for (int yp = y; yp < (y + h); yp++) + { + pixels[offset] = filterRGB(xp, yp, pixels[offset]); + offset++; + } } diff --git a/libjava/java/awt/image/Raster.java b/libjava/java/awt/image/Raster.java index 4fd194e..0fad4ba 100644 --- a/libjava/java/awt/image/Raster.java +++ b/libjava/java/awt/image/Raster.java @@ -128,8 +128,8 @@ public class Raster int w, int h, int bands, Point location) { - // FIXME: Implement; - throw new UnsupportedOperationException("not implemented yet"); + SampleModel sm = new BandedSampleModel(dataType, w, h, bands); + return createWritableRaster(sm, location); } public static WritableRaster createBandedRaster(int dataType, @@ -139,8 +139,9 @@ public class Raster int[] bandOffsets, Point location) { - // FIXME: Implement; - throw new UnsupportedOperationException("not implemented yet"); + SampleModel sm = new BandedSampleModel(dataType, w, h, scanlineStride, + bankIndices, bandOffsets); + return createWritableRaster(sm, location); } public static WritableRaster createPackedRaster(int dataType, @@ -154,6 +155,35 @@ public class Raster return createWritableRaster(sm, location); } + public static WritableRaster createPackedRaster(int dataType, + int w, int h, + int bands, int bitsPerBand, + Point location) + { + if (bands <= 0 || (bands * bitsPerBand > getTypeBits(dataType))) + throw new IllegalArgumentException(); + + SampleModel sm; + + if (bands == 1) + sm = new MultiPixelPackedSampleModel(dataType, w, h, bitsPerBand); + else + { + int[] bandMasks = new int[bands]; + int mask = 0x1; + for (int bits = bitsPerBand; --bits != 0;) + mask = (mask << 1) | 0x1; + for (int i = 0; i < bands; i++) + { + bandMasks[i] = mask; + mask <<= bitsPerBand; + } + + sm = new SinglePixelPackedSampleModel(dataType, w, h, bandMasks); + } + return createWritableRaster(sm, location); + } + public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, int w, int h, int scanlineStride, int pixelStride, @@ -175,8 +205,10 @@ public class Raster int[] bandOffsets, Point location) { - // FIXME: Implement; - throw new UnsupportedOperationException("not implemented yet"); + SampleModel sm = new BandedSampleModel(dataBuffer.getDataType(), + w, h, scanlineStride, + bankIndices, bandOffsets); + return createWritableRaster(sm, dataBuffer, location); } public static WritableRaster @@ -184,7 +216,8 @@ public class Raster int w, int h, int scanlineStride, int[] bandMasks, - Point location) { + Point location) + { SampleModel sm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), w, h, @@ -192,6 +225,19 @@ public class Raster bandMasks); return createWritableRaster(sm, dataBuffer, location); } + + public static WritableRaster + createPackedRaster(DataBuffer dataBuffer, + int w, int h, + int bitsPerPixel, + Point location) + { + SampleModel sm = + new MultiPixelPackedSampleModel(dataBuffer.getDataType(), + w, h, + bitsPerPixel); + return createWritableRaster(sm, dataBuffer, location); + } public static Raster createRaster(SampleModel sm, DataBuffer db, Point location) @@ -329,6 +375,11 @@ public class Raster return height; } + public final int getNumBands() + { + return numBands; + } + public final int getNumDataElements() { return numDataElements; @@ -472,5 +523,24 @@ public class Raster return result.toString(); } - + + // Map from datatype to bits + private static int getTypeBits(int dataType) + { + switch (dataType) + { + case DataBuffer.TYPE_BYTE: + return 8; + case DataBuffer.TYPE_USHORT: + case DataBuffer.TYPE_SHORT: + return 16; + case DataBuffer.TYPE_INT: + case DataBuffer.TYPE_FLOAT: + return 32; + case DataBuffer.TYPE_DOUBLE: + return 64; + default: + return 0; + } + } } diff --git a/libjava/java/awt/image/RasterOp.java b/libjava/java/awt/image/RasterOp.java index 5796180..84d47c1 100644 --- a/libjava/java/awt/image/RasterOp.java +++ b/libjava/java/awt/image/RasterOp.java @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002 Free Software Foundation +/* Copyright (C) 2000, 2002, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -34,11 +34,12 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ + package java.awt.image; +import java.awt.RenderingHints; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; -import java.awt.RenderingHints; public interface RasterOp { diff --git a/libjava/java/awt/image/RescaleOp.java b/libjava/java/awt/image/RescaleOp.java new file mode 100644 index 0000000..cc892b6 --- /dev/null +++ b/libjava/java/awt/image/RescaleOp.java @@ -0,0 +1,218 @@ +/* Copyright (C) 2004 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.awt.image; + +import java.awt.RenderingHints; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +/** + * @author Jerry Quinn (jlquinn@optonline.net) + */ +public class RescaleOp implements BufferedImageOp, RasterOp +{ + private float[] scale; + private float[] offsets; + private RenderingHints hints = null; + + public RescaleOp(float[] scaleFactors, + float[] offsets, + RenderingHints hints) + { + this.scale = scaleFactors; + this.offsets = offsets; + this.hints = hints; + } + + public RescaleOp(float scaleFactor, + float offset, + RenderingHints hints) + { + scale = new float[]{ scaleFactor }; + offsets = new float[]{offset}; + this.hints = hints; + } + + public final float[] getScaleFactors(float[] scaleFactors) + { + if (scaleFactors == null) + scaleFactors = new float[scale.length]; + System.arraycopy(scale, 0, scaleFactors, 0, scale.length); + return scaleFactors; + } + + public final float[] getOffsets(float[] offsets) + { + if (offsets == null) + offsets = new float[this.offsets.length]; + System.arraycopy(this.offsets, 0, offsets, 0, this.offsets.length); + return offsets; + } + + public final int getNumFactors() + { + return scale.length; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getRenderingHints() + */ + public RenderingHints getRenderingHints() + { + return hints; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) + */ + public final BufferedImage filter(BufferedImage src, BufferedImage dst) + { + // TODO Make sure premultiplied alpha is handled correctly. + // TODO See that color conversion is handled. + // TODO figure out how to use rendering hints. + if (scale.length != offsets.length) + throw new IllegalArgumentException(); + + ColorModel scm = src.getColorModel(); + if (dst == null) dst = createCompatibleDestImage(src, null); + + WritableRaster wsrc = src.getRaster(); + WritableRaster wdst = dst.getRaster(); + + // Share constant across colors except alpha + if (scale.length == 1 || scale.length == scm.getNumColorComponents()) + { + // Construct a raster that doesn't include an alpha band. + int[] subbands = new int[scm.getNumColorComponents()]; + for (int i=0; i < subbands.length; i++) subbands[i] = i; + wsrc = + wsrc.createWritableChild(wsrc.minX, wsrc.minY, wsrc.width, wsrc.height, + wsrc.minX, wsrc.minY, subbands); + } + // else all color bands + + filter(wsrc, wdst); + return dst; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster) + */ + public final WritableRaster filter(Raster src, WritableRaster dest) + { + if (dest == null) dest = src.createCompatibleWritableRaster(); + + // Required sanity checks + if (src.numBands != dest.numBands || scale.length != offsets.length) + throw new IllegalArgumentException(); + if (scale.length != 1 && scale.length != src.numBands) + throw new IllegalArgumentException(); + + // Create scaling arrays if needed + float[] lscale = scale; + float[] loff = offsets; + if (scale.length == 1) + { + lscale = new float[src.numBands]; + Arrays.fill(lscale, scale[0]); + loff = new float[src.numBands]; + Arrays.fill(loff, offsets[0]); + } + + // TODO The efficiency here can be improved for various data storage + // patterns, aka SampleModels. + float[] pixel = new float[src.numBands]; + for (int y = src.minY; y < src.height + src.minY; y++) + for (int x = src.minX; x < src.width + src.minX; x++) + { + src.getPixel(x, y, pixel); + for (int b = 0; b < src.numBands; b++) + pixel[b] = pixel[b] * lscale[b] + loff[b]; + dest.setPixel(x, y, pixel); + } + return dest; + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) + */ + public BufferedImage createCompatibleDestImage(BufferedImage src, + ColorModel dstCM) + { + if (dstCM == null) dstCM = src.getColorModel(); + WritableRaster wr = src.getRaster().createCompatibleWritableRaster(); + BufferedImage image + = new BufferedImage(dstCM, wr, src.isPremultiplied, null); + return image; + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#createCompatibleDestRaster(java.awt.image.Raster) + */ + public WritableRaster createCompatibleDestRaster(Raster src) + { + return src.createCompatibleWritableRaster(); + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage) + */ + public final Rectangle2D getBounds2D(BufferedImage src) + { + return src.getRaster().getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster) + */ + public final Rectangle2D getBounds2D(Raster src) + { + return src.getBounds(); + } + + /* (non-Javadoc) + * @see java.awt.image.BufferedImageOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) + */ + public final Point2D getPoint2D(Point2D src, Point2D dst) { + if (dst == null) dst = (Point2D) src.clone(); + else dst.setLocation(src); + return dst; + } + +} diff --git a/libjava/java/awt/image/SampleModel.java b/libjava/java/awt/image/SampleModel.java index a5d65ff..4e3b38b 100644 --- a/libjava/java/awt/image/SampleModel.java +++ b/libjava/java/awt/image/SampleModel.java @@ -456,6 +456,17 @@ public abstract class SampleModel public abstract SampleModel createCompatibleSampleModel(int w, int h); + /** + * Return a SampleModel with a subset of the bands in this model. + * + * Selects bands.length bands from this sample model. The bands chosen + * are specified in the indices of bands[]. This also permits permuting + * the bands as well as taking a subset. Thus, giving an array with + * 1, 2, 3, ..., numbands, will give an identical sample model. + * + * @param bands Array with band indices to include. + * @return A new sample model + */ public abstract SampleModel createSubsetSampleModel(int[] bands); public abstract DataBuffer createDataBuffer(); diff --git a/libjava/java/awt/image/ShortLookupTable.java b/libjava/java/awt/image/ShortLookupTable.java index 223d03b..36beb1d 100644 --- a/libjava/java/awt/image/ShortLookupTable.java +++ b/libjava/java/awt/image/ShortLookupTable.java @@ -61,7 +61,7 @@ public class ShortLookupTable extends LookupTable * * @param offset Offset to be subtracted. * @param data Array of lookup tables. - * @exception IllegalArgumentException if offset < 0 or data.length < 1. + * @exception IllegalArgumentException if offset < 0 or data.length < 1. */ public ShortLookupTable(int offset, short[][] data) throws IllegalArgumentException @@ -78,7 +78,7 @@ public class ShortLookupTable extends LookupTable * * @param offset Offset to be subtracted. * @param data Lookup table for all components. - * @exception IllegalArgumentException if offset < 0. + * @exception IllegalArgumentException if offset < 0. */ public ShortLookupTable(int offset, short[] data) throws IllegalArgumentException @@ -107,14 +107,14 @@ public class ShortLookupTable extends LookupTable * translation arrays. * * @param src Component values of a pixel. - * @param dest Destination array for values, or null. + * @param dst Destination array for values, or null. * @return Translated values for the pixel. */ public int[] lookupPixel(int[] src, int[] dst) throws ArrayIndexOutOfBoundsException { if (dst == null) - dst = new int[numComponents]; + dst = new int[src.length]; if (data.length == 1) for (int i=0; i < src.length; i++) @@ -140,14 +140,14 @@ public class ShortLookupTable extends LookupTable * translation arrays. * * @param src Component values of a pixel. - * @param dest Destination array for values, or null. + * @param dst Destination array for values, or null. * @return Translated values for the pixel. */ public short[] lookupPixel(short[] src, short[] dst) throws ArrayIndexOutOfBoundsException { if (dst == null) - dst = new short[numComponents]; + dst = new short[src.length]; if (data.length == 1) for (int i=0; i < src.length; i++) diff --git a/libjava/java/awt/image/SinglePixelPackedSampleModel.java b/libjava/java/awt/image/SinglePixelPackedSampleModel.java index 578500d..94a9537 100644 --- a/libjava/java/awt/image/SinglePixelPackedSampleModel.java +++ b/libjava/java/awt/image/SinglePixelPackedSampleModel.java @@ -59,6 +59,16 @@ public class SinglePixelPackedSampleModel extends SampleModel int scanlineStride, int[] bitMasks) { super(dataType, w, h, bitMasks.length); + + switch (dataType) + { + case DataBuffer.TYPE_BYTE: + case DataBuffer.TYPE_USHORT: + case DataBuffer.TYPE_INT: + break; + default: + throw new IllegalArgumentException("SinglePixelPackedSampleModel unsupported dataType"); + } this.scanlineStride = scanlineStride; this.bitMasks = bitMasks; @@ -382,7 +392,7 @@ public class SinglePixelPackedSampleModel extends SampleModel * @param y The y-coordinate of the pixel rectangle in <code>obj</code>. * @param w The width of the pixel rectangle in <code>obj</code>. * @param h The height of the pixel rectangle in <code>obj</code>. - * @param obj The primitive array containing the pixels to set. + * @param iArray The primitive array containing the pixels to set. * @param data The DataBuffer to store the pixels into. * @see java.awt.image.SampleModel#setPixels(int, int, int, int, int[], java.awt.image.DataBuffer) */ |