diff options
author | graydon <graydon@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-22 15:36:05 +0000 |
---|---|---|
committer | graydon <graydon@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-22 15:36:05 +0000 |
commit | 69a0b2f4022e9bb7dfac0d1aeaab51df3e38dd56 (patch) | |
tree | f12d115970aa1d943714b44a6955684fbb547d16 /libjava/java/awt | |
parent | 6435a844bc3f47ed26e278156c54606cd13bd238 (diff) | |
download | gcc-69a0b2f4022e9bb7dfac0d1aeaab51df3e38dd56.tar.gz |
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextArea.java
(setLineWrap): Fire property change event after new value is set.
(setTabSize): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JTable.java
(autoCreateColumnsFromModel): New field.
(autoResizeMode): Likewise.
(cellEditor): Likewise.
(cellSelectionEnabled): Likewise.
(columnModel): Likewise.
(dataModel): Likewise.
(defaultEditorsByColumnClass): Likewise.
(defaultRenderersByColumnClass): Likewise.
(editingColumn): Likewise.
(editingRow): Likewise.
(gridColor): Likewise.
(preferredViewportSize): Likewise.
(rowHeight): Likewise.
(rowMargin): Likewise.
(rowSelectionAllowed): Likewise.
(selectionBackground): Likewise.
(selectionForeground): Likewise.
(selectionModel): Likewise.
(showHorizontalLines): Likewise.
(showVerticalLines): Likewise.
(tableHeader): Likewise.
(JTable): Implemented.
(getColumnModel): Likewise.
(getSelectedRow): Likewise.
(getSelectionModel): Likewise.
(setModel): Likewise.
(setSelectionModel): Likewise.
(createScrollPaneForTable): New method.
(createDefaultDataModel): Likewise.
(createDefaultListSelectionModel): Likewise.
(getModel): Likewise.
(getTableHeader): Likewise.
(setTableHeader): Likewise.
(getColumnSelectionAllowed): Likewise.
(setColumnSelectionAllowed): Likewise.
(getRowSelectionAllowed): Likewise.
(setRowSelectionAllowed): Likewise.
(getAutoResizeMode): Likewise.
(setAutoResizeMode): Likewise.
(getColumnCount): Likewise.
(getRowCount): Likewise.
(getCellRenderer): Likewise.
* javax/swing/JTree.java
(cellRenderer): New field.
(editable): Likewise.
(rootVisible): Likewise.
(showsRootHandles): Likewise.
(getModel): New method.
(setModel): Likewise.
(isEditable): Likewise.
(setEditable): Likewise.
(isRootVisbile): Likewise.
(setRootVisible): Likewise.
(getShowsRootHandles): Likewise.
(setShowRootHandles): Likewise.
(getCellRenderer): Likewise.
(setCellRenderer): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JFormattedTextField.java
(setDocument): Implemented.
* javax/swing/JRootPane.java:
Fixed javadocs.
* javax/swing/JTable.java
(getDefaultRenderer): New method.
* javax/swing/JTextField.java
(setFont): Likewise.
(getPreferredSize): Likewise.
* javax/swing/JToggleButton.java
(getAccessibleContext): Fix javadoc.
* javax/swing/JTree.java:
Add some javadocs.
* javax/swing/JViewport.java:
Likewise.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java:
Collect all native method declaration at the top.
(create): Set the filename filter if necessary.
(setDirectory): Call nativeSetDirectory().
(setFilenameFilter): Implement.
(filenameFilterCallback): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(create): Configure dialog to show hidden files.
(filenameFilterCallback): New function.
(nativeSetFilenameFilter): New function.
(nativeSetDirectory): New function.
2004-07-21 Kim Ho <kho@redhat.com>
* javax/swing/plaf/basic/BasicSliderUI.java:
Ran Jalopy.
(paintTrack): Fill the track before painting
the borders.
2004-07-21 Graydon Hoare <graydon@redhat.com>
patch from Roman Kennke <roman@ontographics.com>
* javax/swing/Spring.java: New file.
* javax/swing/SpringLayout.java: New file.
* Makefile.am: Add new files.
* Makefile.in: Regenerate.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* javax/swing/plaf/basic/BasicSplitPaneUI.java: Minor layout fixes.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise.
* javax/swing/ScrollPaneLayout.java: Likewise.
2004-07-21 Kim Ho <kho@redhat.com>
* javax/swing/DefaultDesktopManager.java:
(findMinimum): Removed.
(resizeFrame): Trust the UI to pass valid
bounds.
* javax/swing/JOptionPane.java:
Implemented showInternalXXXDialog methods.
(startModal): New method.
* javax/swing/plaf/basic/BasicInternalFrameUI.java:
(BorderListener::mouseDragged): Verify that the new
bounds are valid before passing them to the DesktopManager.
(preferredLayoutSize): Delegate
to getSize.
(minimumLayoutSize): Ditto.
(getSize): New method.
(GlassPaneDispatcher): Reimplemented by copying
a stripped down LightweightDispatcher from Container.
(getMinimumSize): Call minimumLayoutSize.
* javax/swing/plaf/basic/BasicOptionPaneUI.java:
Ran Jalopy.
(mousePressed): Add ability to properly close
JInternalFrames.
* javax/swing/plaf/basic/BasicToolBarUI.java:
(DragWindow): Set owner for DragWindow.
2004-07-21 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ShortLookupTable.java: New file.
* java/awt/image/ByteLookupTable.java: New file.
* Makefile.am: Added new files.
* Makefile.in: Regenerated.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
(create(GtkContainerPeer)): New native method.
(create()): Call native create(), passing in the parent frame
as the paramter. Natively set the current file and directory.
(setFile): Construct an absolute filename before passing it to
the native peer.
(nativeGetDirectory): New method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
(window_closed): Removed.
(ok_clicked): Likewise.
(cancel_clicked): Likewise.
(handle_response): New method.
(create): Use GtkFileChooserDialog.
(connectSignals): Connect to handle_response.
(nativeGetDirectory): New method.
(nativeSetFile): Use GtkFileChooserDialog.
2004-07-21 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/LookupTable.java: New file.
* Makefile.am: Added new file.
* Makefile.in: Regenerated.
2004-07-21 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/Kernel.java: New file.
* Makefile.am: Added new file.
* Makefile.in: Regenerated.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JCheckBoxMenuItem.java: Fixed Javadocs.
* javax/swing/JMenu.java: Likewise.
* javax/swing/JMenuBar.java: Likewise.
(MARGIN_CHANGED_PROPERTY): New property.
(setMargin): Implemented.
* javax/swing/JMenuItem.java: Fixed javadocs.
* javax/swing/JPopupMenuUI.java: Fixed javadocs.
(LABEL_CHANGED_PROPERTY): New property.
(add): changed to use createActionComponent.
(createActionComponent): Implemented.
(setLabel): Fire PropertyChangeEvent if label property
changes.
* javax/swing/JRadioButtonMenuItem.java: Fixed javadocs.
* javax/swing/plaf/basic/BasicMenuBarUI.java: Likewise.
(ContainerHandler): Repaint if margin property has changed.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(installUI): Call installComponents().
(uninstallUI): Call uinstallComponents().
* javax/swing/plaf/basic/BasicMenuUI.java:
Fixed javadocs.
* javax/swing/plaf/basic/BasicPopupMenuUI.java:
Likewise.
2004-07-21 Kim Ho <kho@redhat.com>
* javax/swing/plaf/basic/BasicToolBarUI.java:
(DragWindow): Use the right constructor.
2004-07-21 Kim Ho <kho@redhat.com>
* javax/swing/JToolBar.java:
(layoutContainer): Use getComponents.
* javax/swing/plaf/basic/BasicToolBarUI.java:
(DragWindow): Don't use SwingUtilities'
getOwnerFrame
(ToolBarDialog): ditto.
2004-07-21 Kim Ho <kho@redhat.com>
* javax/swing/JRootPane.java:
Ran jalopy.
(layoutContainer): Set the glasspane's size to
be the same as the content pane.
(createGlassPane): Set opaque property to false.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Component.java (requestFocus()): Don't handle Panels
specially.
(requestFocus(boolean)): Likewise.
(requestFocusInWindow(boolean)): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c (create):
Set GTK_CAN_FOCUS flag.
2004-07-21 Kim Ho <kho@redhat.com>
* Makefile.am: Added new file.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* javax/swing/AbstractButton.java:
Add rollOverEnabled property.
(setRolloverEnabled): Use new property.
(isRolloverEnabled): Use new property.
* javax/swing/JTabbedPane.java:
(setComponent): Remove useless JTabbedPane.this.
* javax/swing/JToolBar.java: Finish implementation.
* javax/swing/plaf/basic/BasicArrowButton.java:
(paint): Moved border painting to a border.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Change JToolBar look and feel defaults.
* javax/swing/plaf/basic/BasicOptionPaneUI.java
(actionPerformed): Return Integer index instead of name.
(addButtonComponents): Check to see if component is
JButton last.
(createMessageArea): Don't use components that are not
completed yet.
(getIconForType): Use temporary icons.
* javax/swing/plaf/basic/BasicSliderUI.java:
(mousePressed): Do not return if it's on thumb.
(paintMinorTickForHorizSlider): Use BLACK to paint ticks.
(paintMinorTickForVertSlider): ditto.
(paintMajorTickForHorizSlider): ditto.
(paintMajorTickForVertSlider): ditto.
* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
Add a border around the SplitPaneDivider.
* javax/swing/plaf/basic/BasicSplitPaneUI.java:
Remove comments.
* javax/swing/plaf/basic/BasicToolBarSeparatorUI.java:
New file. Implemented.
* javax/swing/plaf/basic/BasicToolBarUI.java:
Implemented.
* testsuite/Makefile.in: Regenerated.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* javax/swing/Timer.java (run): Queue events each time cycle.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkImagePainter.java
(imageComplete): Call image.imageComplete().
* java/awt/image/MemoryImageSource.java:
Reimplement consumers as a Vector instead of a Hashtable. This is
because enumeration on a Hashtable is not thread-safe.
(addConsumer): Adapt to Vector consumers.
(isConsumer): Adapt to Vector consumers.
(removeConsumer): Adapt to Vector consumers.
(startProduction): Adapt to Vector consumers. Call imageComplete()
with STATICIMAGEDONE flag instead of SINGLEFRAME flag.
(newPixels): Adapt to Vector consumers.
(sendPicture): Set the color model of the image consumer.
(newPixels(IIII)): Adapt to Vector consumers.
(newPixels(IIIIB)): Adapt to Vector consumers.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Component.java (deliverEvent): Implement.
(postEvent): Implement.
(handleEvent): Implement.
(translateEvent): New method.
(dispatchEventImpl): Document. Add AWT 1.0 event handling.
* java/awt/Container.java (deliverEvent): Implement.
* java/awt/Event.java (paramString): Fix formatting.
* java/awt/Font.java (toString): Likewise.
* java/awt/Window.java (postEvent): Implement.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
Set window's focus owner upon receiving a FOCUS_LOST event.
* java/awt/Window.java (Window()): Refocus the previously
focused component within the window when the window regains the
top-level focus.
(setFocusOwner): New method.
* java/awt/Component.java (requestFocus): Add FIXME.
* libgcj.pc.in: Remove library flags.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkPanelPeer.java (handleEvent): Handle
MOUSE_PRESSED event.
* java/awt/Component.java (requestFocus()): Handle Panel
specially. Post FOCUS_LOST event on opposite component.
(requestFocus(boolean)): Likewise.
(requestFocusInWindow(boolean)): Likewise.
(paramString): Reorder dimension fields.
* java/awt/Container.java (paramString): Fix string format.
* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
Handle FOCUS_LOST events. Don't handle Windows specially. Only
process key events if the focus owner is non-null.
(dispatchKeyEvent): Likewise.
* java/awt/Frame.java (paramString): Fix formatting.
(generateName): New method.
(getUniqueLong): Likewise.
* java/awt/KeyboardFocusManager.java (getFocusOwner): Check if
the temporary focus owner is null. If so, return the permanent
focus owner.
* java/awt/Panel.java (generateName): New method.
(getUniqueLong): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: Rework
signal handling to make callbacks more specific.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/Position.java
(Bias): Implemented.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/LookAndFeel.java
(provideErrorFeedback): New method.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JTextArea.java
(tabSize): New field.
(getTabSize): New method.
(setTabSize): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/ActionMap.java:
Fixed javadocs all over.
(serialVersionUID): Made private.
(parent): Don't explicitely initialize with default value.
(get): SImplified.
(keys): Reimplemented.
(allKeys): Likewise.
(convertSet): Removed.
* javax/swing/ComponentInputMap.java:
Fixed javadocs all over.
(ComponentInputMap): Implemented.
(put): Likewise.
(clear): Likewise.
(remove): Likewise.
(SetParent): Likewise.
(getComponent): Likewise.
* javax/swing/InputMap.java:
Fixed javadocs all over.
(serialVersionUID): Made private.
(parent): Don't explicitely initialize with default value.
(get): SImplified.
(keys): Reimplemented.
(allKeys): Likewise.
(convertSet): Removed.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/ActionMap.java,
javax/swing/ComponentInputMap.java,
javax/swing/InputMap.java,
javax/swing/table/DefaultTableColumnModel.java,
javax/swing/table/TableColumn.java,
javax/swing/table/TableColumnModel.java,
javax/swing/table/TableModel.java,
javax/swing/text/AbstractDocument.java,
javax/swing/text/TextAction.java:
Reformated.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* gnu/java/awt/peer/gtk/GtkToolkit.java (bufferedImageOrError):
Make method non-static.
* javax/swing/AbstractButton.java:
Rename fields to match property names where possible.
(iconTextGap): New property.
* javax/swing/JCheckBox.java: Match AbstractButton changes.
(init) New method, call from after various constructors.
* javax/swing/JComponent.java (revalidate):
Invalidate before queueing repair.
* javax/swing/JList.java (getPreferredScrollableViewportSize):
Reimplement in terms of visibleRowCount property.
* javax/swing/JMenuButton.java: Match AbstractButton changes.
* javax/swing/JScrollPane.java (createScrollListener):
Remove tracing chatter.
* javax/swing/JToggleButton.java: Match AbstractButton changes.
* javax/swing/RepaintManager.java (addInvalidComponent):
Don't invalidate.
* javax/swing/ScrollPaneLayout.java: Various corrections to layout
calculations.
* javax/swing/SwingUtilities.java (layoutCompoundLabel):
Mimic sun behavior on top left/right positioning.
* javax/swing/ViewportLayout.java (preferredLayoutSize):
Remove mistaken use of preferredScrollableViewportSize here.
(layoutContainer): Use view's preferred size as basis.
* javax/swing/plaf/basic/BasicButtonUI.java:
Set, get, and use textIconGap property.
(paint) Paint text returned from layout (with ellipsis).
* javax/swing/plaf/basic/BasicListUI.java:
Remove tracing chatter, correct various minor calculations.
(getCellBounds): Update layout state before calculating.
* javax/swing/plaf/basic/BasicLookAndFeel.java (Button.Margin):
Use margin default similar to sun's.
* javax/swing/plaf/basic/BasicScrollBarUI.java (ArrowIcon):
(createIncreaseIcon): Center icon, minimize margins.
(createDecreaseIcon): Likewise.
* javax/swing/plaf/basic/BasicScrollPaneUI.java (installDefaults):
Implement.
(installUI): Call it.
(uninstallDefaults): Implement.
(uninstallUI): Call it.
* javax/swing/plaf/basic/BasicToolBarUI.java (DragWindow):
Call existing Window constructor.
* javax/swing/plaf/basic/BasicViewportUI.java (paint):
Set clip before painting.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JMenuItem.java:
(processMouseEvent): Reimplemented to deal with
mouse drag events.
(createMenuDragMouseEvent): New private helper method.
Creates MenuDragMouseEvent.
* javax/swing/MenuSelectionManager.java
(componentForPoint): Implemented.
(isComponentPartOfCurrentMenu): Made public.
(processMouseEvent): Reimplemented to deal with
mouse drag events.
(setSelectedPath): Corrected small mistake that caused
path to be set incorrectly.
(getPath): If given component is JMenu then also add this
menu's popup menu to the selected path.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(getPath): Ditto.
(getPreferredSize): Call getPreferredMenuItemSize().
(getPreferredItemSize): Moved code from getPreferredSize to here.
(installListeners): Install MouseMotionListeners.
(MouseInputHandler): Pass mouse release event to MenuSelectionManager
if mouse wasn't released in the bounds of this menu item.
(MenuDragMouseHandler): Implemented.
* javax/swing/plaf/basic/BasicMenuUI.java:
(installListeners): Install MouseMotionListener and
MenuDrageMouseListener.
(MenuDragMouseHandler): Implemented.
* javax/swing/plaf/basic/BasicPopupMenuUI.java:
(uninstallListeners): Implemented.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JCheckBox.java: Reformated.
(JCheckBox): Fixed all constructors.
(isBorderPaintedFlat): New method.
(setBorderPaintedFlat): New method.
* javax/swing/JEditorPane.java
(createEditorKitForContentType): Made public.
(scrollToReference): Likewise.
* javax/swing/JTextArea.java
(setLineWrap): Fire property change.
* javax/swing/JToggleButton.java
(JToggleButton): New constructor.
(JToggleButton): Simplified.
* javax/swing/text/AttributeSet.java
(FontAttribute): Renamed from FontCharacterAttribute.
* javax/swing/text/JTextComponent.java
(KeyBinBinding): Added javadoc.
(JTextComponent): Likewise.
(getAccessibleContext): Fixed javadoc.
* javax/swing/text/View.java
(View): Added javadoc.
* javax/swing/text/TabableView.java: New file.
* Makefile.am: Added javax/swing/text/TabableView.java.
* Makefile.in: Regenerated.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* java/awt/image/BufferedImage.java (getSource): Remove tracing chatter.
* gnu/java/awt/peer/gtk/GtkToolkit.java
(GtkErrorImage): New helper class.
(bufferedImageOrError): New helper method.
(createImage): Use it.
2004-07-21 David Jee <djee@redhat.com>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
(setCaretPosition): Scroll the text view so the new caret position
is visible on screen.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkContainerPeer.java
(setBounds): Do not validate awtComponent here.
* gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
(getPreferredSize): New method.
* java/awt/ScrollPane.java
(ScrollPane): Set default size to 100x100.
(addNotify): If child is not a Panel, wrap it with a new Panel.
(paramString): Implement.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JMenu.java:
(setSelected): Display popup menu only if this menu
is showing on the screen.
* javax/swing/JPopupMenu.java:
(processMouseEvent): Added comment.
(processKeyEvent): Likewise.
* javax/swing/MenuSelectionManager.java:
(clearSelectedPath): Only fireStateChanged() after
selected path was changed, not before.
(setSelectedPath): Likewise.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(paintMenuItem): Corrected position of menu item's
icon.
* javax/swing/plaf/basic/BasicPopupMenuUI.java:
(installUI): Correct setDefaultLightWeightPopupEnabled call.
(popupMenuCanceled): Reimplemented.
(popupMenuWillBecomeVisible): Select first menu item by default
when displaying free floating popup menus.
(TopWindowListener): Reimplemented.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* java/awt/Panel.java (dispatchEventImpl): Override to prevent
Panel from being painted twice when it is first shown.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* java/awt/Window.java: Reverted changes from my
previous patch for creating window without an owner.
* javax/swing/SwingUtilities.java:
(SwingUtilities.OwnerFrame): made static.
(OwnerFrame.setVisible): New method. Overridden with
empty implementation.
(OwnerFrame.isShowing): New method. Ovverridden
to return always true.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(GtkComponentPeer): Remove temporary try/catch block.
(setVisible): Call show and hide.
(show): Make native.
(hide): Likewise.
(getArgs): Don't add "visible" argument.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(property_notify_predicate): Return Bool instead of int.
(find_layout): New function.
(connectJObject): Call find_layout.
(connectSignals): Likewise.
(moveLayout): Likewise.
(gtkLayoutSetVisible): Likewise.
2004-07-21 Mark Wielaard <mark@klomp.org>
* java/awt/event/InvocationEvent.java (dispatch): Synchronize
on notifier object before calling notifyAll().
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* java/awt/Window.java: Changed constructors to use new
method that is described below. Constructors call this
methods only if newly created window should have an owner.
(setWindowOwner): New method. Implementation for
this method is moved from this(owner,configuration).
* javax/swing/JWindow.java:
(JWindow): Reimplement to use SwingUtilities.ownerFrame
instead of owner.
* javax/swing/SwingUtilities.java:
(ownerFrame): Change type of this field to OwnerFrame.
(getOwnerFrame): Changed to return object of type OwnerFrame.
(SwingUtilities.OwnerFrame): New class. Represents owner
of a Window that is not provided with one.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/AbstractButton.java:
(configurePropertiesFromAction): Set action command
to button's text by default if action command is not
explicitely specified.
* javax/swing/JMenu.java: Remove unnecessary listener
and methods relevant to it.
(setSelected): Reimplemented.
(menuSelectionChanged): Moved most part of implementation to
setSelected() and call it instead.
* javax/swing/JMenuItem.java:
(init): Comment out statement that sets paint_border to false.
(configurePropertiesFromAction): Do not set accelerator
for JMenu.
(menuSelectionChanged): Change selected index in the selection
model of menu item's parent.
* javax/swing/JPopupMenu.java:
(remove): Set constraints.fill field to GridBagConstraints.BOTH
instead of GridBagConstraints.HORIZONTAL.
(insert): Likewise.
(createActionChangeListener): Implemented.
(setVisible): Correct location of HeavyWeightMenu and
don't firePopupMenuCanceled().
(menuSelectionChanged): Implemented.
(ActionChangeListener): New Listener. Implemented.
* javax/swing/plaf/basic/BasicMenuBarUI.java:
(BasicMenuBarUI.ContainerHandler): Implemented.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(paintMenuItem): Uncommented out code that paints
icon, now that icons are working properly.
(PropertyChangeListener): Implemented.
* javax/swing/plaf/basic/BasicPopupMenuUI.java:
Added javadocs.
(topWindowListener): New field.
(Constructor): initialize topWindowListener.
(BasicPopupMenuUI.TopWindowListener): Implemented.
(BasicPopupMenuUI.PopupMenuHandler): Implemented.
(BasicPopupMenuUI.TopWindowListener): New ComponentListener.
Implemented.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicButtonUI.java
(paintFocus): Fixed method signature.
(paintButtonPressed): Likewise.
(paintButtonNormal): Likewise.
(paintText): New method.
* javax/swing/plaf/basic/BasicLabelUI.java
(paint): Re-indented.
* javax/swing/plaf/basic/BasicTextUI.java
(installUI): Set parent textComponent to opaque.
* javax/swing/text/DefaultHighlighter.java
(checkPositions): New helper method.
(addHighlight): Throws BadLocationException, check positions.
(changeHighlight): Likewise.
* javax/swing/text/EditorKit.java
(EditorKit): Implements Serializable.
* javax/swing/text/JTextComponent.java
(getUI): Added javadoc.
(setUI): Likewise.
(upadteUI): Added javadoc, don't revalidate and repaint.
2004-07-21 David Jee <djee@redhat.com>
* java/awt/GridBagLayout.java
(ArrangeGrid): Use PREFERREDSIZE instead of MINSIZE.
* javax/swing/AbstractButton.java
(setText): Reindent.
* javax/swing/RepaintManager.java
(addInvalidComponent): Find the first ancestor that isValidateRoot().
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JFormattedTextField.java
(value): New field.
(JFormattedTextField): Implemented.
(getValue): Likewise.
(setValue): Likewise.
* javax/swing/LookAndFeel.java
(getSupportsWindowDecorations): New method.
* javax/swing/UIDefaults.java:
Use java.beans.PropertyChangeSupport instead of doing all ourself.
(addPropertyChangeListener): Made public.
(addResourceBundle): Likewise.
(removeResourceBundle): Likewise.
(setDefaultLocale): Likewise.
* javax/swing/plaf/basic/BasicRootPaneUI.java
(BasicRootPaneUI): Implements PropertyChangeListener.
(propertyChange): New method.
* javax/swing/plaf/basic/BasicTextUI.java
(BasicHighlighter): New inner class.
(createHighlighter): New method.
* javax/swing/plaf/basic/BasicToolBarUI.java
(DragWindow): Extends java.awt.Window.
* javax/swing/text/JTextComponent.java
(getDocument): Removed debug output.
* javax/swing/plaf/basic/BasicTextFieldUI.java,
javax/swing/text/DefaultHighlighter.java,
javax/swing/text/FieldView.java,
javax/swing/text/PlainView.java: New files.
* Makefile.am: Added new files.
* Makefile.in: Regenerated.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JEditorPane.java
(createDefaultEditorKit): Use javax.swing.text.DefaultEditorKit.
(createEditorKitForContentType): Likewise.
* javax/swing/text/DefaultEditorKit.java
(serialVersionUID): Added constant field.
(EndOfLineStringPropery): Fixed typo.
(DefaultEditorKit): New constructor.
* javax/swing/text/Segment.java:
Import java.text.CharacterIterator.
* javax/swing/text/CharacterIterator.java,
javax/swing/text/PlainEditorKit.java: Removed.
* Makefile.am: Removed javax/swing/text/CharacterIterator.java and
javax/swing/text/PlainEditorKit.java.
* Makefile.in: Regenerated.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JButton.java,
javax/swing/text/DefaultEditorKit.java,
javax/swing/text/EditorKit.java,
javax/swing/text/Segment.java,
javax/swing/text/StyledEditorKit.java:
Reformatted.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/ImageIcon.java
(file): Removed.
(description): Renamed from descr.
(ImageIcon): Added missing constructors.
(setParent): Removed.
(setImageObserver): New method.
(getImageObserver): New method.
(paintIcon): Handle observer = null.
* javax/swing/JButton.java
(removeNotify): Fixed javadoc.
(updateUI): Simplified.
* javax/swing/JRootPane.java
(serialVersionUID): New constant field.
* javax/swing/UIManager.java:
Fixed javadocs all over.
(setLookAndFeel): Throws UnsupportedLookAndFeelException.
* javax/swing/text/AbstractDocument.java
(createPosition): Throws BadLocationException.
(getText): Likewise.
(remove): Likewise.
* javax/swing/text/ComponentView.java
(modelToView): Likewise.
* javax/swing/text/DefaultEditorKit.java:
Made all public methods public.
(read): Throws BadLocationException and IOException.
(write): Likewise.
* javax/swing/text/EditorKit.java:
Made all public methods public.
(serialVersionUID): New constant field.
(clone): New method.
(read): Throws BadLocationException and IOException.
(write): Likewise.
* javax/swing/text/Segment.java
(array): Made public.
(count): Likewise.
(offset): Likewise.
(Segment): New constructors.
(clone): Reimplemented.
* javax/swing/text/StyledEditorKit.java
(serialVersionUID): New constant field.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* java/awt/image/BufferedImage.java
(getSource): Implement.
* javax/swing/ImageIcon.java
(ImageIcon): Implement ctor.
* javax/swing/ScrollPaneLayout.java
(preferredLayoutSize): Be more careful about nulls.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/AttributeSet.java
(CharacterAttribute): New interface
(ColorAttribute): Likewise.
(FontCharacterAttribute): Likewise.
(ParagraphAttribute): Likewise.
* javax/swing/text/DefaultCaret.java
(moveCaret): New method.
(positionCaret): Likewise.
(repaint): Made protected.
* javax/swing/text/JTextComponent.java
(KeyBinding): Made it static.
* javax/swing/text/View.java
(getContainer): Honor parent == null.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/AbstractDocument.java:
Reformatted.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicRootPaneUI.java:
Import javax.swing.UIManager explicitely.
* javax/swing/plaf/basic/BasicTabbedPaneUI.java
(ScrollingButton): Made it static.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/UIDefaults.java
(ActiveValue): Made public.
(LazyValue): Likewise.
* javax/swing/plaf/basic/BasicTextUI.java
(RootView): Reintroduced.
(view): Removed.
(rootView): New field.
(installUI): Create document if needed, initialize rootView.
(uninstallUI): Hanle rootView.
(paint): Likewise.
(getRootView): Likewise.
(setView): Likewise.
* javax/swing/text/DefaultCaret.java:
Renamed all "evt" variables to "event".
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* libgcj.spec.in: Add -l-java-util-logging.
2004-07-21 Andreas Tobler <a.tobler@schweiz.ch>
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
(init_dpi_conversion_factor): Check for int_dpi < 0 in case
gtk-xft-dpi can no calculate the right value.
(dpi_changed_cb): Mark *pspec as unsused.
2004-07-21 David Jee <djee@redhat.com>
* java/awt/Component.java
(move): Delegate to setBounds().
(resize): Likewise.
(reshape): Fix so it repaints parent and self only when necessary.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(GtkComponentPeer): Revert previous patch from 2004-06-22.
(setVisible): Likewise.
(show): Likewise.
(hide): Likewise.
(getArgs): Likewise.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(property_notify_predicate): Likewise.
(find_layout): Likewise.
(connectJObject): Likewise.
(connectSignals): Likewise.
(moveLayout): Likewise.
(gtkLayoutSetVisible): Likewise.
2004-07-21 Graydon Hoare <graydon@redhat.com>
* Makefile.am
(jv_convert_LDADD):
(gij_LDADD):
(rmic_LDADD):
(rmiregistry_LDADD): Add lib-java-util-logging.la
* Makefile.in: Regenerate.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/AbstractDocument.java
(replace): Dont use protected method of java.util.Vector directly.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicTextUI.java
(installUI): Call specialized install methods.
(installDefaults): New method.
(installListeners): Likewise.
(installKeyboardActions): Likewise.
(uninstallUI): Likewise.
(uninstallDefaults): New method.
(uninstallListeners): Likewise.
(uninstallKeyboardActions): Likewise.
(getPropertyPrefix): New abstract method.
(paint): Made final, just call paintSafely().
(paintSavely): New method.
(paintBackground): Likewise.
(getVisibleEditorRect): Likewise.
* javax/swing/text/LayeredHighlighter.java,
javax/swing/text/TabExpander.java: New files.
* Makefile.am: Added javax/swing/text/LayeredHighlighter.java
and javax/swing/text/TabExpander.java.
* Makefile.in: Regenerated.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicTextUI.java
(BasicTextUI): Made abstract.
(BasicCaret): New inner class.
(view): Don't explicitely initialize with "null".
(textComponent): New field.
(textColor): Removed.
(disabledTextColor): Removed.
(normalBackgroundColor): Removed.
(RootView): Removed commented out inner class.
(createUI): Removed.
(createCaret): New method.
(getComponent): Likewise.
(installUI): Initialize textComponent only.
(getPreferredSize): Use installed JTextComponent.
(setView): New method.
(create): Likewise.
* javax/swing/text/JTextComponent.java
(highlighter): New field.
(caretColor): Likewise.
(disabledTextColor): Likewise.
(seletedTextColor): Likewise.
(selectionColor): Likewise.
(setUI): New method.
(getCaretColor): Likewise.
(setCaretColor): Likewise.
(getDisabledColor): Likewise.
(setDisabledColor): Likewise.
(getSelectedTextColor): Likewise.
(setSelectedTextColor): Likewise.
(getSelectionColor): Likewise.
(setSelectionColor): Likewise.
(getHighlighter): Likewise.
(setHighlighter): Likewise.
(replaceSelection): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/plaf/basic/BasicScrollPaneUI.java
(BasicScrollPaneUI): Implements ScrollPaneConstants.
* javax/swing/plaf/basic/BasicToolBarUI.java
(BasicToolBarUI): Implements SwingConstants.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JPopupMenu.java: Removed CVS tags.
* javax/swing/UIDefaults.java: Reformatted.
* javax/swing/plaf/basic/BasicRootPaneUI.java:
Explicitely import used classes.
2004-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(GtkComponentPeer): Remove temporary try/catch block.
(setVisible): Call show and hide.
(show): Make native.
(hide): Likewise.
(getArgs): Don't add "visible" argument.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
(property_notify_predicate): Return Bool instead of int.
(find_layout): New function.
(connectJObject): Call find_layout.
(connectSignals): Likewise.
(moveLayout): Likewise.
(gtkLayoutSetVisible): Likewise.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/AbstractButton.java:
(setDisplayedMnemonicIndex): Check if button
text is not null before checking its length.
* javax/swing/JMenuItem.java:
(processMouseEvent): Disarm menu item if mouse has
exited it.
* javax/swing/plaf/basic/BasicMenuUI.java:
(MouseInputHandler.mouseEntered): Do not raise
popup menu if this menu is already selected.
(MouseInputHandler.mousePressed): Do not fire
MenuEvents.
(MenuHandler): Implemented.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/JCheckBoxMenuItem.java: Added Javadoc.
(getSelectedObjects): Implemented.
* javax/swing/JRadioButtonMenuItem.java: Added Javadoc.
* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java:
Added javadoc for few methods.
(processMouseEvent): Made public.
* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
(processMouseEvent): Likewise.
2004-07-21 Olga Rodimina <rodimina@redhat.com>
* javax/swing/AbstractButton.java:
(init): Set display mnemonic index to -1.
(setMnemonic(char)): Use setMnemonic(int).
(setMnemonic(int)): Set display mnemonic index.
(getDisplayedMnemonicIndex): Change method signature
by removing 'index' parameter.
* javax/swing/plaf/basic/BasicLookAndFeel.java:
Added default for Menu.selectionBackground.
* javax/swing/plaf/basic/BasicMenuItemUI.java:
(paintMenuItem): Change background color of the selected
menu item.
(paintText): Paint differently when menu item is disabled.
Also paint mnemonic if it appears in the menu item's label.
(paintAccelerator): Paint accelerator differently
if menu item is disabled.
* javax/swing/plaf/basic/BasicMenuUI.java:
(installDefaults): Install defaults for
selectionForeground and selectionBackground.
(uninstallDefaults): Uninstall defauls for
selectionForeground and selectionBackground.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/AbstractDocument.java
(BranchElement): Implemented.
(LeafElement): Implemented.
* javax/swing/text/DefaultCaret.java:
Import used classes.
(serialVersionUID): New constant.
* javax/swing/text/JTextComponent.java
(AccessibleJTextComponent): Removed dead declaration.
(caretPos): Removed.
(setCaret): New method.
* javax/swing/text/PlainDocument.java
(rootElement): New field.
(PlainDocument): Initialize rootElement.
(createDefaultRoot): New method.
(getDefaultRootElement): Implemented.
* javax/swing/text/View.java: Reformatted.
* javax/swing/text/ViewFactory.java
(create): Added javadoc.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/ToolTipManager.java: Reformatted.
2004-07-21 Rodimina Olga <rodimina@redhat.com>
* javax/swing/AbstractButton.java
(changeEvent): New field.
(fireItemStateChanged): Change source of the event
to 'this' before firing it to button listeners.
(fireActionPerformed): Likewise.
(fireStateChanged): Likewise.
(createActionListener): Do not set source
of the event to AbstractButton.
* javax/swing/plaf/basic/BasicMenuBarUI.java:
(ContainerHandler.componentAdded): Removed
print out statement.
(ContainerHandler.componentRemoved): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/text/Highlighter.java: New file.
* Makefile.am: Added javax/swing/text/Highlighter.java.
* Makefile.in: Regenerated.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/ToolTipManager.java
(stillInsideTimerAction): Fixed constructor arguments.
(outsideTimerAction): Likewise.
(insideTimerAction): Likewise.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JButton.java: Reformatted.
* javax/swing/JFormattedTextField.java
(getUIClassID): Implemented.
* javax/swing/JRootPane.java
(serialVersionUID): New constant.
* javax/swing/JTextField.java
(align): New field.
(JTextField): Simplified.
(getUIClassID): New method.
(getActionListeners): Added @since tag.
(setColumns): Invalidate layout and repaint.
(getHorizontalAlignment): New method.
(setHorizontalAlignment): New method.
(selectAll): Removed.
* javax/swing/SwingUtilities.java
(getAncestorOfClass): Removed redundant @see tag.
(isLeftMouseButton): Fixed implementation.
(isMiddleMouseButton): Likewise.
(isRightMouseButton): Likewise.
* javax/swing/text/AbstractDocument.java
(AttributeContext.addAttribute): New method.
(AttributeContext.addAttributes): New method.
(AttributeContext.getEmptySet): New method.
(AttributeContext.reclaim): New method.
(AttributeContext.removeAttribute): New method.
(AttributeContext.removeAttributes): New method.
* javax/swing/text/Document.java
(createPosition): Throws BadLocationException.
(getText): Likewise.
(remove): Likewise.
* javax/swing/text/JTextComponent.java
(getText): Return null if no document is set. Catch
BadLocationException.
(getUI): Return ui.
(updateUI): Simplified.
2004-07-21 Michael Koch <konqueror@gmx.de>
* javax/swing/JButton.java
(removeNotify): Fixed javadoc.
(updateUI): Simplified.
2004-07-21 David Jee <djee@redhat.com>
* gnu/java/awt/image/ImageDecoder.java
(startProduction): Only add consumer if it's not added yet.
* gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
(GdkPixbufDecoder): Don't call initState() here.
(produce): Call initState() here, to ensure area_prepared and
area_updated signals are properly connected.
* gnu/java/awt/peer/gtk/GtkImage.java
(setColorModel): Use equals() to compare ColorModel objects.
(setPixels): Likewise.
* java/awt/image/ColorModel.java
(equals): Fix typo. Use Arrays.equals() to compare int arrays.
* java/awt/image/RGBImageFilter.java
(setColorModel): Set consumer's color model.
(setPixels): Use equals() to compare ColorModel objects.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85051 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/awt')
-rw-r--r-- | libjava/java/awt/Component.java | 403 | ||||
-rw-r--r-- | libjava/java/awt/Container.java | 12 | ||||
-rw-r--r-- | libjava/java/awt/DefaultKeyboardFocusManager.java | 34 | ||||
-rw-r--r-- | libjava/java/awt/Event.java | 3 | ||||
-rw-r--r-- | libjava/java/awt/Font.java | 5 | ||||
-rw-r--r-- | libjava/java/awt/Frame.java | 95 | ||||
-rw-r--r-- | libjava/java/awt/GridBagLayout.java | 2 | ||||
-rw-r--r-- | libjava/java/awt/KeyboardFocusManager.java | 5 | ||||
-rw-r--r-- | libjava/java/awt/Panel.java | 63 | ||||
-rw-r--r-- | libjava/java/awt/ScrollPane.java | 26 | ||||
-rw-r--r-- | libjava/java/awt/Window.java | 50 | ||||
-rw-r--r-- | libjava/java/awt/image/BufferedImage.java | 54 | ||||
-rw-r--r-- | libjava/java/awt/image/ByteLookupTable.java | 162 | ||||
-rw-r--r-- | libjava/java/awt/image/ColorModel.java | 5 | ||||
-rw-r--r-- | libjava/java/awt/image/Kernel.java | 136 | ||||
-rw-r--r-- | libjava/java/awt/image/LookupTable.java | 109 | ||||
-rw-r--r-- | libjava/java/awt/image/MemoryImageSource.java | 45 | ||||
-rw-r--r-- | libjava/java/awt/image/RGBImageFilter.java | 4 | ||||
-rw-r--r-- | libjava/java/awt/image/ShortLookupTable.java | 162 |
19 files changed, 1215 insertions, 160 deletions
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index f3153da5911..5cb792b1de4 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.awt; import java.awt.dnd.DropTarget; +import java.awt.event.ActionEvent; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; @@ -48,6 +49,7 @@ import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.InputEvent; import java.awt.event.InputMethodEvent; import java.awt.event.InputMethodListener; import java.awt.event.MouseEvent; @@ -1175,30 +1177,7 @@ public abstract class Component */ public void move(int x, int y) { - int oldx = this.x; - int oldy = this.y; - - if (this.x == x && this.y == y) - return; - invalidate (); - this.x = x; - this.y = y; - if (peer != null) - peer.setBounds (x, y, width, height); - - // Erase old bounds and repaint new bounds for lightweights. - if (isLightweight() && width != 0 && height !=0) - { - parent.repaint(oldx, oldy, width, height); - repaint(); - } - - if (oldx != x || oldy != y) - { - ComponentEvent ce = new ComponentEvent(this, - ComponentEvent.COMPONENT_MOVED); - getToolkit().getSystemEventQueue().postEvent(ce); - } + setBounds(x, y, this.width, this.height); } /** @@ -1262,32 +1241,7 @@ public abstract class Component */ public void resize(int width, int height) { - int oldwidth = this.width; - int oldheight = this.height; - - if (this.width == width && this.height == height) - return; - invalidate (); - this.width = width; - this.height = height; - if (peer != null) - peer.setBounds (x, y, width, height); - - // Erase old bounds and repaint new bounds for lightweights. - if (isLightweight()) - { - if (oldwidth != 0 && oldheight != 0 && parent != null) - parent.repaint(x, y, oldwidth, oldheight); - if (width != 0 && height != 0) - repaint(); - } - - if (oldwidth != width || oldheight != height) - { - ComponentEvent ce = - new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); - getToolkit().getSystemEventQueue().postEvent(ce); - } + setBounds(this.x, this.y, width, height); } /** @@ -1395,9 +1349,25 @@ public abstract class Component // Erase old bounds and repaint new bounds for lightweights. if (isLightweight()) { - if (oldwidth != 0 && oldheight != 0 && parent != null) + boolean shouldRepaintParent = false; + boolean shouldRepaintSelf = false; + + if (parent != null) + { + Rectangle parentBounds = parent.getBounds(); + Rectangle oldBounds = new Rectangle(parent.getX() + oldx, + parent.getY() + oldy, + oldwidth, oldheight); + Rectangle newBounds = new Rectangle(parent.getX() + x, + parent.getY() + y, + width, height); + shouldRepaintParent = parentBounds.intersects(oldBounds); + shouldRepaintSelf = parentBounds.intersects(newBounds); + } + + if (shouldRepaintParent) parent.repaint(oldx, oldy, oldwidth, oldheight); - if (width != 0 && height != 0) + if (shouldRepaintSelf) repaint(); } @@ -2255,14 +2225,17 @@ public abstract class Component } /** - * AWT 1.0 event dispatcher. + * AWT 1.0 event delivery. * - * @param e the event to dispatch + * Deliver an AWT 1.0 event to this Component. This method simply + * calls {@link #postEvent}. + * + * @param e the event to deliver * @deprecated use {@link #dispatchEvent(AWTEvent)} instead */ public void deliverEvent(Event e) { - // XXX Add backward compatibility handling. + postEvent (e); } /** @@ -2284,16 +2257,24 @@ public abstract class Component } /** - * AWT 1.0 event dispatcher. + * AWT 1.0 event handler. * - * @param e the event to dispatch - * @return false: since the method was deprecated, the return has no meaning + * This method simply calls handleEvent and returns the result. + * + * @param e the event to handle + * @return the result of handling <code>e</code> * @deprecated use {@link #dispatchEvent(AWTEvent)} instead */ public boolean postEvent(Event e) { - // XXX Add backward compatibility handling. - return false; + boolean handled = handleEvent (e); + + if (!handled) + // FIXME: need to translate event coordinates to parent's + // coordinate space. + handled = getParent ().postEvent (e); + + return handled; } /** @@ -3170,20 +3151,61 @@ public abstract class Component } /** - * AWT 1.0 event processor. + * AWT 1.0 event handler. + * + * This method calls one of the event-specific handler methods. For + * example for key events, either {@link #keyDown (Event evt, int + * key)} or {@link keyUp (Event evt, int key)} is called. A derived + * component can override one of these event-specific methods if it + * only needs to handle certain event types. Otherwise it can + * override handleEvent itself and handle any event. * * @param evt the event to handle - * @return false: since the method was deprecated, the return has no meaning + * @return true if the event was handled, false otherwise * @deprecated use {@link #processEvent(AWTEvent)} instead */ public boolean handleEvent(Event evt) { - // XXX Add backward compatibility handling. + switch (evt.id) + { + // Handle key events. + case Event.KEY_ACTION: + case Event.KEY_PRESS: + return keyDown (evt, evt.key); + case Event.KEY_ACTION_RELEASE: + case Event.KEY_RELEASE: + return keyUp (evt, evt.key); + + // Handle mouse events. + case Event.MOUSE_DOWN: + return mouseDown (evt, evt.x, evt.y); + case Event.MOUSE_UP: + return mouseUp (evt, evt.x, evt.y); + case Event.MOUSE_MOVE: + return mouseMove (evt, evt.x, evt.y); + case Event.MOUSE_DRAG: + return mouseDrag (evt, evt.x, evt.y); + case Event.MOUSE_ENTER: + return mouseEnter (evt, evt.x, evt.y); + case Event.MOUSE_EXIT: + return mouseExit (evt, evt.x, evt.y); + + // Handle focus events. + case Event.GOT_FOCUS: + return gotFocus (evt, evt.arg); + case Event.LOST_FOCUS: + return lostFocus (evt, evt.arg); + + // Handle action event. + case Event.ACTION_EVENT: + return action (evt, evt.arg); + } + // Unknown event. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 mouse event handler. * * @param evt the event to handle * @param x the x coordinate, ignored @@ -3686,7 +3708,20 @@ public abstract class Component // lightweight component. In either case we want to // post a FOCUS_GAINED event. EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue (); - eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED)); + synchronized (eq) + { + KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager (); + Component currentFocusOwner = manager.getGlobalPermanentFocusOwner (); + if (currentFocusOwner != null) + { + eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, + false, this)); + eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false, + currentFocusOwner)); + } + else + eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false)); + } } } else @@ -3759,9 +3794,25 @@ public abstract class Component // lightweight component. In either case we want to // post a FOCUS_GAINED event. EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue (); + synchronized (eq) + { + KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager (); + Component currentFocusOwner = manager.getGlobalPermanentFocusOwner (); + if (currentFocusOwner != null) + { + eq.postEvent (new FocusEvent(currentFocusOwner, + FocusEvent.FOCUS_LOST, + temporary, this)); + eq.postEvent (new FocusEvent(this, + FocusEvent.FOCUS_GAINED, + temporary, + currentFocusOwner)); + } + else eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary)); } } + } else // FIXME: need to add a focus listener to our top-level // ancestor, so that we can post this event when it becomes @@ -3852,7 +3903,8 @@ public abstract class Component // Check if top-level ancestor is currently focused window. if (focusedWindow == toplevel) { - if (peer != null) + if (peer != null + && !(this instanceof Window)) // This call will cause a FOCUS_GAINED event to be // posted to the system event queue if the native // windowing system grants the focus request. @@ -3863,9 +3915,21 @@ public abstract class Component // lightweight component. In either case we want to // post a FOCUS_GAINED event. EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue (); + synchronized (eq) + { + Component currentFocusOwner = manager.getGlobalPermanentFocusOwner (); + if (currentFocusOwner != null) + { + eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, + temporary, this)); + eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary, + currentFocusOwner)); + } + else eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary)); } } + } else return false; } @@ -4041,8 +4105,8 @@ public abstract class Component String name = getName(); if (name != null) param.append(name).append(","); - param.append(width).append("x").append(height).append("+").append(x) - .append("+").append(y); + param.append(x).append(",").append(y).append(",").append(width) + .append("x").append(height); if (! isValid()) param.append(",invalid"); if (! isVisible()) @@ -4410,13 +4474,212 @@ p * <li>the set of backward traversal keys } /** - * Implementation of dispatchEvent. Allows trusted package classes to - * dispatch additional events first. + * Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0 + * event ({@link Event}). + * + * @param e an AWT 1.1 event to translate + * + * @return an AWT 1.0 event representing e + */ + private Event translateEvent (AWTEvent e) + { + Component target = (Component) e.getSource (); + Event translated = null; + + if (e instanceof InputEvent) + { + InputEvent ie = (InputEvent) e; + long when = ie.getWhen (); + + int oldID = 0; + int id = e.getID (); + + int oldMods = 0; + int mods = ie.getModifiers (); + + if ((mods & InputEvent.BUTTON2_MASK) != 0) + oldMods |= Event.META_MASK; + else if ((mods & InputEvent.BUTTON3_MASK) != 0) + oldMods |= Event.ALT_MASK; + + if ((mods & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) + oldMods |= Event.SHIFT_MASK; + + if ((mods & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) + oldMods |= Event.CTRL_MASK; + + if ((mods & (InputEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0) + oldMods |= Event.META_MASK; + + if ((mods & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0) + oldMods |= Event.ALT_MASK; + + if (e instanceof MouseEvent) + { + if (id == MouseEvent.MOUSE_PRESSED) + oldID = Event.MOUSE_DOWN; + else if (id == MouseEvent.MOUSE_RELEASED) + oldID = Event.MOUSE_UP; + else if (id == MouseEvent.MOUSE_MOVED) + oldID = Event.MOUSE_MOVE; + else if (id == MouseEvent.MOUSE_DRAGGED) + oldID = Event.MOUSE_DRAG; + else if (id == MouseEvent.MOUSE_ENTERED) + oldID = Event.MOUSE_ENTER; + else if (id == MouseEvent.MOUSE_EXITED) + oldID = Event.MOUSE_EXIT; + else + // No analogous AWT 1.0 mouse event. + return null; + + MouseEvent me = (MouseEvent) e; + + translated = new Event (target, when, oldID, + me.getX (), me.getY (), 0, oldMods); + } + else if (e instanceof KeyEvent) + { + if (id == KeyEvent.KEY_PRESSED) + oldID = Event.KEY_PRESS; + else if (e.getID () == KeyEvent.KEY_RELEASED) + oldID = Event.KEY_RELEASE; + else + // No analogous AWT 1.0 key event. + return null; + + int oldKey = 0; + int newKey = ((KeyEvent) e).getKeyCode (); + switch (newKey) + { + case KeyEvent.VK_BACK_SPACE: + oldKey = Event.BACK_SPACE; + break; + case KeyEvent.VK_CAPS_LOCK: + oldKey = Event.CAPS_LOCK; + break; + case KeyEvent.VK_DELETE: + oldKey = Event.DELETE; + break; + case KeyEvent.VK_DOWN: + case KeyEvent.VK_KP_DOWN: + oldKey = Event.DOWN; + break; + case KeyEvent.VK_END: + oldKey = Event.END; + break; + case KeyEvent.VK_ENTER: + oldKey = Event.ENTER; + break; + case KeyEvent.VK_ESCAPE: + oldKey = Event.ESCAPE; + break; + case KeyEvent.VK_F1: + oldKey = Event.F1; + break; + case KeyEvent.VK_F10: + oldKey = Event.F10; + break; + case KeyEvent.VK_F11: + oldKey = Event.F11; + break; + case KeyEvent.VK_F12: + oldKey = Event.F12; + break; + case KeyEvent.VK_F2: + oldKey = Event.F2; + break; + case KeyEvent.VK_F3: + oldKey = Event.F3; + break; + case KeyEvent.VK_F4: + oldKey = Event.F4; + break; + case KeyEvent.VK_F5: + oldKey = Event.F5; + break; + case KeyEvent.VK_F6: + oldKey = Event.F6; + break; + case KeyEvent.VK_F7: + oldKey = Event.F7; + break; + case KeyEvent.VK_F8: + oldKey = Event.F8; + break; + case KeyEvent.VK_F9: + oldKey = Event.F9; + break; + case KeyEvent.VK_HOME: + oldKey = Event.HOME; + break; + case KeyEvent.VK_INSERT: + oldKey = Event.INSERT; + break; + case KeyEvent.VK_LEFT: + case KeyEvent.VK_KP_LEFT: + oldKey = Event.LEFT; + break; + case KeyEvent.VK_NUM_LOCK: + oldKey = Event.NUM_LOCK; + break; + case KeyEvent.VK_PAUSE: + oldKey = Event.PAUSE; + break; + case KeyEvent.VK_PAGE_DOWN: + oldKey = Event.PGDN; + break; + case KeyEvent.VK_PAGE_UP: + oldKey = Event.PGUP; + break; + case KeyEvent.VK_PRINTSCREEN: + oldKey = Event.PRINT_SCREEN; + break; + case KeyEvent.VK_RIGHT: + case KeyEvent.VK_KP_RIGHT: + oldKey = Event.RIGHT; + break; + case KeyEvent.VK_SCROLL_LOCK: + oldKey = Event.SCROLL_LOCK; + break; + case KeyEvent.VK_TAB: + oldKey = Event.TAB; + break; + case KeyEvent.VK_UP: + case KeyEvent.VK_KP_UP: + oldKey = Event.UP; + break; + default: + oldKey = newKey; + } + + translated = new Event (target, when, oldID, + 0, 0, oldKey, oldMods); + } + } + else if (e instanceof ActionEvent) + translated = new Event (target, Event.ACTION_EVENT, + ((ActionEvent) e).getActionCommand ()); + + return translated; + } + + /** + * Implementation of dispatchEvent. Allows trusted package classes + * to dispatch additional events first. This implementation first + * translates <code>e</code> to an AWT 1.0 event and sends the + * result to {@link #postEvent}. If the AWT 1.0 event is not + * handled, and events of type <code>e</code> are enabled for this + * component, e is passed on to {@link #processEvent}. * * @param e the event to dispatch */ void dispatchEventImpl(AWTEvent e) { + Event oldEvent = translateEvent (e); + + if (oldEvent != null) + postEvent (oldEvent); + if (eventTypeEnabled (e.id)) processEvent(e); } diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java index ffd81b46802..6c70e940e8e 100644 --- a/libjava/java/awt/Container.java +++ b/libjava/java/awt/Container.java @@ -856,6 +856,16 @@ public class Container extends Component */ public void deliverEvent(Event e) { + if (!handleEvent (e)) + { + synchronized (getTreeLock ()) + { + Component parent = getParent (); + + if (parent != null) + parent.deliverEvent (e); + } + } } /** @@ -1027,7 +1037,7 @@ public class Container extends Component { String param = super.paramString(); if (layoutMgr != null) - param = param + "," + layoutMgr.getClass().getName(); + param = param + ",layout=" + layoutMgr.getClass().getName(); return param; } diff --git a/libjava/java/awt/DefaultKeyboardFocusManager.java b/libjava/java/awt/DefaultKeyboardFocusManager.java index c4dd7eac609..d4c8bdd4fa8 100644 --- a/libjava/java/awt/DefaultKeyboardFocusManager.java +++ b/libjava/java/awt/DefaultKeyboardFocusManager.java @@ -162,16 +162,41 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { Component target = (Component) e.getSource (); - if (e.id == FocusEvent.FOCUS_GAINED - && !(target instanceof Window)) + if (e.id == FocusEvent.FOCUS_GAINED) { if (((FocusEvent) e).isTemporary ()) setGlobalFocusOwner (target); else setGlobalPermanentFocusOwner (target); } + else if (e.id == FocusEvent.FOCUS_LOST) + { + // We need to set the window's focus owner here; we can't + // set it when the window loses focus because by that time + // the previous focus owner has already lost focus + // (FOCUS_LOST events are delivered before + // WINDOW_LOST_FOCUS events). + + // Find the target Component's top-level ancestor. + Container parent = target.getParent (); + + while (parent != null + && !(parent instanceof Window)) + parent = parent.getParent (); + + Window toplevel = parent == null ? + (Window) target : (Window) parent; + + Component focusOwner = getFocusOwner (); + if (focusOwner != null) + toplevel.setFocusOwner (focusOwner); + + if (((FocusEvent) e).isTemporary ()) + setGlobalFocusOwner (null); + else + setGlobalPermanentFocusOwner (null); + } - if (!(target instanceof Window)) target.dispatchEvent (e); return true; @@ -192,6 +217,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager // processKeyEvent checks if this event represents a focus // traversal key stroke. Component focusOwner = getGlobalPermanentFocusOwner (); + + if (focusOwner != null) processKeyEvent (focusOwner, (KeyEvent) e); if (e.isConsumed ()) @@ -230,6 +257,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { Component focusOwner = getGlobalPermanentFocusOwner (); + if (focusOwner != null) focusOwner.dispatchEvent (e); // Loop through all registered KeyEventPostProcessors, giving diff --git a/libjava/java/awt/Event.java b/libjava/java/awt/Event.java index 79be0e8c861..57e7c79f232 100644 --- a/libjava/java/awt/Event.java +++ b/libjava/java/awt/Event.java @@ -163,7 +163,8 @@ public class Event implements java.io.Serializable protected String paramString () { - return "id=" + id + ",x=" + x + ",y=" + y + "target=" + target; + return "id=" + id + ",x=" + x + ",y=" + y + + ",target=" + target + ",arg=" + arg; } public boolean shiftDown() diff --git a/libjava/java/awt/Font.java b/libjava/java/awt/Font.java index 4c70c735797..6a3514758b7 100644 --- a/libjava/java/awt/Font.java +++ b/libjava/java/awt/Font.java @@ -1268,10 +1268,9 @@ toString() return(getClass().getName() + "(logical=" + getName () + ",family=" + getFamily () - + ",face=" + getFontName () + + ",name=" + getFontName () + ",style=" + getStyle () - + ",size=" + getSize () - + ",transform=" + getTransform () + ")"); + + ",size=" + getSize ()); } diff --git a/libjava/java/awt/Frame.java b/libjava/java/awt/Frame.java index c92585a6f6b..dd8cdeb00d1 100644 --- a/libjava/java/awt/Frame.java +++ b/libjava/java/awt/Frame.java @@ -50,11 +50,6 @@ import java.util.Vector; */ public class Frame extends Window implements MenuContainer { - -/* - * Static Variables - */ - /** * Constant for the default cursor. * @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead. @@ -148,12 +143,6 @@ public static final int NORMAL = 0; // Serialization version constant private static final long serialVersionUID = 2673458971256075116L; -/*************************************************************************/ - -/* - * Instance Variables - */ - /** * @serial The version of the class data being serialized * // FIXME: what is this value? @@ -208,11 +197,10 @@ private String title = ""; */ private boolean undecorated = false; -/*************************************************************************/ - /* - * Constructors + * The number used to generate the name returned by getName. */ + private static transient long next_frame_number = 0; /** * Initializes a new instance of <code>Frame</code> that is not visible @@ -224,8 +212,6 @@ Frame() this(""); } -/*************************************************************************/ - /** * Initializes a new instance of <code>Frame</code> that is not visible * and has the specified title. @@ -256,12 +242,6 @@ Frame(String title, GraphicsConfiguration gc) visible = false; } -/*************************************************************************/ - -/* - * Instance Methods - */ - /** * Returns this frame's title string. * @@ -273,8 +253,6 @@ getTitle() return(title); } -/*************************************************************************/ - /* * Sets this frame's title to the specified value. * @@ -288,8 +266,6 @@ setTitle(String title) ((FramePeer) peer).setTitle(title); } -/*************************************************************************/ - /** * Returns this frame's icon. * @@ -302,8 +278,6 @@ getIconImage() return(icon); } -/*************************************************************************/ - /** * Sets this frame's icon to the specified value. * @@ -317,8 +291,6 @@ setIconImage(Image icon) ((FramePeer) peer).setIconImage(icon); } -/*************************************************************************/ - /** * Returns this frame's menu bar. * @@ -331,8 +303,6 @@ getMenuBar() return(menuBar); } -/*************************************************************************/ - /** * Sets this frame's menu bar. * @@ -352,8 +322,6 @@ setMenuBar(MenuBar menuBar) this.menuBar = menuBar; } -/*************************************************************************/ - /** * Tests whether or not this frame is resizable. This will be * <code>true</code> by default. @@ -367,8 +335,6 @@ isResizable() return(resizable); } -/*************************************************************************/ - /** * Sets the resizability of this frame to the specified value. * @@ -383,8 +349,6 @@ setResizable(boolean resizable) ((FramePeer) peer).setResizable(resizable); } -/*************************************************************************/ - /** * Returns the cursor type of the cursor for this window. This will * be one of the constants in this class. @@ -399,8 +363,6 @@ getCursorType() return(getCursor().getType()); } -/*************************************************************************/ - /** * Sets the cursor for this window to the specified type. The specified * type should be one of the constants in this class. @@ -415,8 +377,6 @@ setCursor(int type) setCursor(new Cursor(type)); } -/*************************************************************************/ - /** * Removes the specified component from this frame's menu. * @@ -428,8 +388,6 @@ remove(MenuComponent menu) menuBar.remove(menu); } -/*************************************************************************/ - /** * Notifies this frame that it should create its native peer. */ @@ -450,17 +408,40 @@ public void removeNotify() super.removeNotify(); } -/*************************************************************************/ - /** * Returns a debugging string describing this window. * * @return A debugging string describing this window. */ -protected String -paramString() + protected String paramString () { - return(getClass().getName()); + String title = getTitle (); + + String resizable = ""; + if (isResizable ()) + resizable = ",resizable"; + + String state = ""; + switch (getState ()) + { + case NORMAL: + state = ",normal"; + break; + case ICONIFIED: + state = ",iconified"; + break; + case MAXIMIZED_BOTH: + state = ",maximized-both"; + break; + case MAXIMIZED_HORIZ: + state = ",maximized-horiz"; + break; + case MAXIMIZED_VERT: + state = ",maximized-vert"; + break; + } + + return super.paramString () + ",title=" + title + resizable + state; } public static Frame[] @@ -553,5 +534,19 @@ getFrames() this.undecorated = undecorated; } -} // class Frame + /** + * Generate a unique name for this frame. + * + * @return A unique name for this frame. + */ + String generateName () + { + return "frame" + getUniqueLong (); + } + + private static synchronized long getUniqueLong () + { + return next_frame_number++; + } +} diff --git a/libjava/java/awt/GridBagLayout.java b/libjava/java/awt/GridBagLayout.java index b98359c1bdb..1239f2cf7f4 100644 --- a/libjava/java/awt/GridBagLayout.java +++ b/libjava/java/awt/GridBagLayout.java @@ -340,7 +340,7 @@ public class GridBagLayout if (components.length == 0) return; - GridBagLayoutInfo info = getLayoutInfo (parent, MINSIZE); + GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE); if (info.cols == 0 && info.rows == 0) return; layoutInfo = info; diff --git a/libjava/java/awt/KeyboardFocusManager.java b/libjava/java/awt/KeyboardFocusManager.java index 8ebd9e1713c..e82c0d48825 100644 --- a/libjava/java/awt/KeyboardFocusManager.java +++ b/libjava/java/awt/KeyboardFocusManager.java @@ -246,7 +246,10 @@ public abstract class KeyboardFocusManager */ public Component getFocusOwner () { - return (Component) getObject (currentFocusOwners); + Component owner = (Component) getObject (currentFocusOwners); + if (owner == null) + owner = (Component) getObject (currentPermanentFocusOwners); + return owner; } /** diff --git a/libjava/java/awt/Panel.java b/libjava/java/awt/Panel.java index b84c0d0a6a3..dbe322896d7 100644 --- a/libjava/java/awt/Panel.java +++ b/libjava/java/awt/Panel.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.awt; +import java.awt.event.PaintEvent; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -62,6 +63,19 @@ public class Panel extends Container implements Accessible /** The cached accessible context. */ private transient AccessibleContext context; + /** Flag set when the first system-requested paint event is + dispatched. */ + private transient boolean initialSystemUpdateDone; + + /** Flag set when the first application-requested paint event is + consumed. */ + private transient boolean initialUpdateConsumed; + + /* + * The number used to generate the name returned by getName. + */ + private static transient long next_panel_number = 0; + /** * Initializes a new instance of <code>Panel</code> that has a default * layout manager of <code>FlowLayout</code>. @@ -84,6 +98,36 @@ public class Panel extends Container implements Accessible } /** + * Consume initial application-requested paint event if it has not + * already been consumed, and if the initial system-requested paint + * event has not already been handled. Otherwise, call + * super.dispatchEventImpl. These extra steps are required to + * prevent a Panel from being painted twice when it is initially + * shown. + * + * @param e the event to dispatch + */ + void dispatchEventImpl (AWTEvent e) + { + if (e instanceof PaintEvent) + { + if (e.id == PaintEvent.UPDATE) + { + if (!initialUpdateConsumed + && !initialSystemUpdateDone) + { + e.consume (); + initialUpdateConsumed = true; + } + } + else if (e.id == PaintEvent.PAINT) + initialSystemUpdateDone = true; + } + else + super.dispatchEventImpl (e); + } + + /** * Notifies this object to create its native peer. * * @see #isDisplayable() @@ -141,5 +185,20 @@ public class Panel extends Container implements Accessible { return AccessibleRole.PANEL; } - } // class AccessibleAWTPanel -} // class Panel + } + + /** + * Generate a unique name for this panel. + * + * @return A unique name for this panel. + */ + String generateName () + { + return "panel" + getUniqueLong (); + } + + private static synchronized long getUniqueLong () + { + return next_panel_number++; + } +} diff --git a/libjava/java/awt/ScrollPane.java b/libjava/java/awt/ScrollPane.java index b772bee3878..457df0c0e26 100644 --- a/libjava/java/awt/ScrollPane.java +++ b/libjava/java/awt/ScrollPane.java @@ -157,6 +157,9 @@ ScrollPane(int scrollbarDisplayPolicy) } wheelScrollingEnabled = true; + + // Default size. + setSize(100,100); } /*************************************************************************/ @@ -400,6 +403,15 @@ addNotify() setPeer((ComponentPeer)getToolkit().createScrollPane(this)); super.addNotify(); + + Component[] list = getComponents(); + if (list != null && list.length > 0 && ! (list[0] instanceof Panel)) + { + Panel panel = new Panel(); + panel.setLayout(new BorderLayout()); + panel.add(list[0], BorderLayout.CENTER); + add(panel); + } } /*************************************************************************/ @@ -527,7 +539,19 @@ printComponents(Graphics graphics) public String paramString() { - return(getClass().getName()); + Insets insets = getInsets(); + return getName() + "," + + getX() + "," + + getY() + "," + + getWidth() + "x" + getHeight() + "," + + "ScrollPosition=(" + scrollPosition.getX() + "," + + scrollPosition.getY() + ")," + + "Insets=(" + insets.top + "," + + insets.left + "," + + insets.bottom + "," + + insets.right + ")," + + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + "," + + "wheelScrollingEnabled=" + isWheelScrollingEnabled(); } /** diff --git a/libjava/java/awt/Window.java b/libjava/java/awt/Window.java index 7fa471ee73b..7397a1c1c33 100644 --- a/libjava/java/awt/Window.java +++ b/libjava/java/awt/Window.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.awt; import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowFocusListener; import java.awt.event.WindowListener; @@ -85,6 +87,8 @@ public class Window extends Container implements Accessible private transient boolean shown; + private transient Component windowFocusOwner; + /** * This (package access) constructor is used by subclasses that want * to build windows that do not have parents. Eg. toplevel @@ -98,6 +102,33 @@ public class Window extends Container implements Accessible // cycle roots. focusCycleRoot = true; setLayout(new BorderLayout()); + + addWindowFocusListener (new WindowAdapter () + { + public void windowGainedFocus (WindowEvent event) + { + if (windowFocusOwner != null) + { + // FIXME: move this section and the other similar + // sections in Component into a separate method. + EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue (); + synchronized (eq) + { + KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager (); + Component currentFocusOwner = manager.getGlobalPermanentFocusOwner (); + if (currentFocusOwner != null) + { + eq.postEvent (new FocusEvent (currentFocusOwner, FocusEvent.FOCUS_LOST, + false, windowFocusOwner)); + eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED, + false, currentFocusOwner)); + } + else + eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED, false)); + } + } + } + }); } Window(GraphicsConfiguration gc) @@ -658,8 +689,22 @@ public class Window extends Container implements Accessible // The currently-focused Component belongs to the active Window. if (activeWindow == this) return manager.getFocusOwner (); + else + return windowFocusOwner; + } - return null; + /** + * Set the focus owner for this window. This method is used to + * remember which component was focused when this window lost + * top-level focus, so that when it regains top-level focus the same + * child component can be refocused. + * + * @param windowFocusOwner the component in this window that owns + * the focus. + */ + void setFocusOwner (Component windowFocusOwner) + { + this.windowFocusOwner = windowFocusOwner; } /** @@ -671,8 +716,7 @@ public class Window extends Container implements Accessible */ public boolean postEvent(Event e) { - // FIXME - return false; + return handleEvent (e); } /** diff --git a/libjava/java/awt/image/BufferedImage.java b/libjava/java/awt/image/BufferedImage.java index 547301da8d8..b18779af146 100644 --- a/libjava/java/awt/image/BufferedImage.java +++ b/libjava/java/awt/image/BufferedImage.java @@ -47,6 +47,8 @@ import java.awt.Transparency; import java.awt.color.ColorSpace; import java.util.Hashtable; import java.util.Vector; +import java.util.HashSet; +import java.util.Iterator; import gnu.java.awt.ComponentDataBlitOp; /** @@ -442,7 +444,57 @@ public class BufferedImage extends Image public ImageProducer getSource() { - throw new UnsupportedOperationException("not implemented"); + return new ImageProducer() { + + HashSet consumers = new HashSet(); + + public void addConsumer(ImageConsumer ic) + { + consumers.add(ic); + } + + public boolean isConsumer(ImageConsumer ic) + { + return consumers.contains(ic); + } + + public void removeConsumer(ImageConsumer ic) + { + consumers.remove(ic); + } + + public void startProduction(ImageConsumer ic) + { + int x = 0; + int y = 0; + int width = getWidth(); + int height = getHeight(); + int stride = width; + int offset = 0; + int[] pixels = getRGB(x, y, + width, height, + (int[])null, offset, stride); + ColorModel model = getColorModel(); + + consumers.add(ic); + + Iterator i = consumers.iterator(); + while(i.hasNext()) + { + ImageConsumer c = (ImageConsumer) i.next(); + c.setHints(ImageConsumer.SINGLEPASS); + c.setDimensions(getWidth(), getHeight()); + c.setPixels(x, y, width, height, model, pixels, offset, stride); + c.imageComplete(ImageConsumer.STATICIMAGEDONE); + } + } + + public void requestTopDownLeftRightResend(ImageConsumer ic) + { + startProduction(ic); + } + + }; } public Vector getSources() diff --git a/libjava/java/awt/image/ByteLookupTable.java b/libjava/java/awt/image/ByteLookupTable.java new file mode 100644 index 00000000000..572f6e9212d --- /dev/null +++ b/libjava/java/awt/image/ByteLookupTable.java @@ -0,0 +1,162 @@ +/* ByteLookupTable.java -- Java class for a pixel translation table. + Copyright (C) 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; + +/** + * ByteLookupTable represents translation arrays for pixel values. It wraps + * one or more data arrays for each layer (or component) in an image, such as + * Alpha, R, G, and B. When doing translation, the offset is subtracted from + * the pixel values to allow a subset of an array to be used. + * + * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a> + * @version 1.0 + */ +public class ByteLookupTable extends LookupTable +{ + // Array of translation tables. + private byte data[][]; + + /** + * Creates a new <code>ByteLookupTable</code> instance. + * + * Offset is subtracted from pixel values when looking up in the translation + * tables. If data.length is one, the same table is applied to all pixel + * components. + * + * @param offset Offset to be subtracted. + * @param data Array of lookup tables. + * @exception IllegalArgumentException if offset < 0 or data.length < 1. + */ + public ByteLookupTable(int offset, byte[][] data) + throws IllegalArgumentException + { + super(offset, data.length); + this.data = data; + } + + /** + * Creates a new <code>ByteLookupTable</code> instance. + * + * Offset is subtracted from pixel values when looking up in the translation + * table. The same table is applied to all pixel components. + * + * @param offset Offset to be subtracted. + * @param data Lookup table for all components. + * @exception IllegalArgumentException if offset < 0. + */ + public ByteLookupTable(int offset, byte[] data) + throws IllegalArgumentException + { + super(offset, 1); + this.data = new byte[][] {data}; + } + + /** Return the lookup tables. */ + public final byte[][] getTable() + { + return data; + } + + /** + * Return translated values for a pixel. + * + * For each value in the pixel src, use the value minus offset as an index + * in the component array and copy the value there to the output for the + * component. If dest is null, the output is a new array, otherwise the + * translated values are written to dest. Dest can be the same array as + * src. + * + * For example, if the pixel src is [2, 4, 3], and offset is 1, the output + * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the + * translation arrays. + * + * @param src Component values of a pixel. + * @param dest 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]; + + if (data.length == 1) + for (int i=0; i < src.length; i++) + dst[i] = data[0][src[i] - offset]; + else + for (int i=0; i < src.length; i++) + dst[i] = data[i][src[i] - offset]; + + return dst; + } + + /** + * Return translated values for a pixel. + * + * For each value in the pixel src, use the value minus offset as an index + * in the component array and copy the value there to the output for the + * component. If dest is null, the output is a new array, otherwise the + * translated values are written to dest. Dest can be the same array as + * src. + * + * For example, if the pixel src is [2, 4, 3], and offset is 1, the output + * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the + * translation arrays. + * + * @param src Component values of a pixel. + * @param dest 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]; + + if (data.length == 1) + for (int i=0; i < src.length; i++) + dst[i] = data[0][((int)src[i]) - offset]; + else + for (int i=0; i < src.length; i++) + dst[i] = data[i][((int)src[i]) - offset]; + + return dst; + + } +} diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java index c73f4fd4e58..87ab942917a 100644 --- a/libjava/java/awt/image/ColorModel.java +++ b/libjava/java/awt/image/ColorModel.java @@ -37,6 +37,7 @@ exception statement from your version. */ package java.awt.image; +import java.util.Arrays; import java.awt.Point; import java.awt.Transparency; import java.awt.color.ColorSpace; @@ -551,8 +552,8 @@ public abstract class ColorModel implements Transparency (transferType == o.transferType) && (transparency == o.transparency) && (hasAlpha == o.hasAlpha) && - (isAlphaPremultiplied == isAlphaPremultiplied) && - (bits.equals(o.bits)) && + (isAlphaPremultiplied == o.isAlphaPremultiplied) && + Arrays.equals(bits, o.bits) && (cspace.equals(o.cspace)); } diff --git a/libjava/java/awt/image/Kernel.java b/libjava/java/awt/image/Kernel.java new file mode 100644 index 00000000000..27d6ddd8fae --- /dev/null +++ b/libjava/java/awt/image/Kernel.java @@ -0,0 +1,136 @@ +/* Kernel.java -- Java class for an image processing kernel + Copyright (C) 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; + +/** + * Kernel represents an image processing kernel. It gets used to hold + * convolution filters among other purposes. It stores an array of float + * values representing a 2-dimensional array in row-major order. + * + * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a> + * @version 1.0 + */ +public class Kernel implements Cloneable +{ + private final int width; + private final int height; + private final float[] data; + + /** + * Creates a new <code>Kernel</code> instance. + * + * @param width The 2D width of data. + * @param height The 2D height of data. + * @param data The source data array. + * @exception IllegalArgumentException if width * height < data.length. + */ + public Kernel(int width, int height, float[] data) + throws IllegalArgumentException + { + this.width = width; + this.height = height; + if (data.length < width * height || width < 0 || height < 0) + throw new IllegalArgumentException(); + this.data = new float[width * height]; + System.arraycopy(data, 0, this.data, 0, width * height); + } + + /** + * Return the X origin: (width - 1) / 2 + */ + public final int getXOrigin() + { + return (width - 1) / 2; + } + + /** + * Return the Y origin: (height - 1) / 2 + */ + public final int getYOrigin() + { + return (height - 1) / 2; + } + + /** + * @return The kernel width. + */ + public final int getWidth() + { + return width; + } + + /** + * @return The kernel height. + */ + public final int getHeight() + { + return height; + } + + /** + * Return the kernel data. + * + * If data is null, allocates a new array and returns it. Otherwise, the + * kernel values are copied into data. + * + * @param data Array to copy values into, or null. + * @return The array with copied values. + * @exception IllegalArgumentException if data != null and too small. + */ + public final float[] getKernelData(float[] data) + throws IllegalArgumentException + { + if (data == null) + return (float[])this.data.clone(); + + if (data.length < this.data.length) + throw new IllegalArgumentException(); + + System.arraycopy(this.data, 0, data, 0, this.data.length); + return data; + } + + /** + * @return a clone of this Kernel. + */ + public Object clone() + { + return new Kernel(width, height, data); + } +} diff --git a/libjava/java/awt/image/LookupTable.java b/libjava/java/awt/image/LookupTable.java new file mode 100644 index 00000000000..eb89795c2c8 --- /dev/null +++ b/libjava/java/awt/image/LookupTable.java @@ -0,0 +1,109 @@ +/* LookupTable.java -- Java class for a pixel translation table. + Copyright (C) 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; + +/** + * LookupTable represents translation arrays for pixel values. It wraps one + * or more data arrays for each layer (or component) in an image, such as + * Alpha, R, G, and B. When doing translation, the offset is subtracted from + * the pixel values to allow a subset of an array to be used. + * + * @see ByteLookupTable + * @see ShortLookupTable + * + * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a> + * @version 1.0 + */ +public abstract class LookupTable +{ + // Not protected since that's part of the public API. + int offset; + int numComponents; + + /** + * Creates a new <code>LookupTable</code> instance. + * + * If numComponents is 1, the same translation table is used for all pixel + * components. + * + * @param offset Offset to be subtracted. + * @param numComponents Number of image components. + * @exception IllegalArgumentException if offset < 0 or numComponents < 1. + */ + protected LookupTable(int offset, int numComponents) + throws IllegalArgumentException + { + if (offset < 0 || numComponents < 1) + throw new IllegalArgumentException(); + this.offset = offset; + this.numComponents = numComponents; + } + + /** Return the number of components. */ + public int getNumComponents() + { + return numComponents; + } + + /** Return the offset. */ + public int getOffset() + { + return offset; + } + + + /** + * Return translated values for a pixel. + * + * For each value in the pixel src, use the value minus offset as an index + * in the component array and copy the value there to the output for the + * component. If dest is null, the output is a new array, otherwise the + * translated values are written to dest. Dest can be the same array as + * src. + * + * For example, if the pixel src is [2, 4, 3], and offset is 1, the output + * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the + * translation arrays. + * + * @param src Component values of a pixel. + * @param dest Destination array for values, or null. + * @return Translated values for the pixel. + */ + public abstract int[] lookupPixel(int[] src, int[] dest); +} diff --git a/libjava/java/awt/image/MemoryImageSource.java b/libjava/java/awt/image/MemoryImageSource.java index d86119993ec..ddd5800f14f 100644 --- a/libjava/java/awt/image/MemoryImageSource.java +++ b/libjava/java/awt/image/MemoryImageSource.java @@ -41,6 +41,7 @@ package java.awt.image; import java.awt.Image; import java.util.Enumeration; import java.util.Hashtable; +import java.util.Vector; public class MemoryImageSource implements ImageProducer { @@ -49,7 +50,8 @@ public class MemoryImageSource implements ImageProducer private int pixeli[], width, height, offset, scansize; private byte pixelb[]; private ColorModel cm; - private Hashtable props, consumers = new Hashtable(); + private Hashtable props = new Hashtable(); + private Vector consumers = new Vector(); /** Constructs an ImageProducer from memory @@ -126,10 +128,10 @@ public class MemoryImageSource implements ImageProducer * <code>ImageProducer</code>. */ public synchronized void addConsumer(ImageConsumer ic) { - if (consumers.containsKey(ic)) + if (consumers.contains(ic)) return; - consumers.put(ic, ic); + consumers.addElement(ic); } /** @@ -137,7 +139,7 @@ public class MemoryImageSource implements ImageProducer * already registered with this <code>ImageProducer</code>. */ public synchronized boolean isConsumer(ImageConsumer ic) { - if (consumers.containsKey(ic)) + if (consumers.contains(ic)) return true; return false; } @@ -147,7 +149,7 @@ public class MemoryImageSource implements ImageProducer * registered consumers for this <code>ImageProducer</code>. */ public synchronized void removeConsumer(ImageConsumer ic) { - consumers.remove(ic); + consumers.removeElement(ic); } /** @@ -157,16 +159,16 @@ public class MemoryImageSource implements ImageProducer * registered consumers. */ public void startProduction(ImageConsumer ic) { - if (!(consumers.containsKey(ic))) { - consumers.put(ic, ic); + if (!(consumers.contains(ic))) { + consumers.addElement(ic); } - Enumeration e = consumers.elements(); - for( ; e.hasMoreElements(); ) { - ic = (ImageConsumer)e.nextElement(); + + Vector list = (Vector) consumers.clone(); + for(int i = 0; i < list.size(); i++) { + ic = (ImageConsumer) list.elementAt(i); sendPicture( ic ); - ic.imageComplete( ImageConsumer.SINGLEFRAME ); + ic.imageComplete( ImageConsumer.STATICIMAGEDONE ); } - } /** @@ -210,9 +212,9 @@ public class MemoryImageSource implements ImageProducer { if( animated == true ) { ImageConsumer ic; - Enumeration e = consumers.elements(); - for( ; e.hasMoreElements(); ) { - ic = (ImageConsumer)e.nextElement(); + Vector list = (Vector) consumers.clone(); + for(int i = 0; i < list.size(); i++) { + ic = (ImageConsumer) list.elementAt(i); sendPicture( ic ); ic.imageComplete( ImageConsumer.SINGLEFRAME ); } @@ -227,6 +229,7 @@ public class MemoryImageSource implements ImageProducer ic.setProperties( props ); } ic.setDimensions(width, height); + ic.setColorModel(cm); if( pixeli != null ) { ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize ); } else { @@ -249,9 +252,9 @@ public class MemoryImageSource implements ImageProducer newPixels(); } else { ImageConsumer ic; - Enumeration e = consumers.elements(); - for( ; e.hasMoreElements(); ) { - ic = (ImageConsumer)e.nextElement(); + Vector list = (Vector) consumers.clone(); + for(int i = 0; i < list.size(); i++) { + ic = (ImageConsumer) list.elementAt(i); ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT ); if( props != null ) { ic.setProperties( props ); @@ -294,9 +297,9 @@ public class MemoryImageSource implements ImageProducer newPixels(); } else { ImageConsumer ic; - Enumeration e = consumers.elements(); - for( ; e.hasMoreElements(); ) { - ic = (ImageConsumer)e.nextElement(); + Vector list = (Vector) consumers.clone(); + for(int i = 0; i < list.size(); i++) { + ic = (ImageConsumer) list.elementAt(i); ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT ); if( props != null ) { ic.setProperties( props ); diff --git a/libjava/java/awt/image/RGBImageFilter.java b/libjava/java/awt/image/RGBImageFilter.java index 5718024e761..819580e0057 100644 --- a/libjava/java/awt/image/RGBImageFilter.java +++ b/libjava/java/awt/image/RGBImageFilter.java @@ -79,6 +79,10 @@ public abstract class RGBImageFilter extends ImageFilter if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) { newmodel = filterIndexColorModel( (IndexColorModel) model ); + consumer.setColorModel(newmodel); + } + else { + consumer.setColorModel(ColorModel.getRGBdefault()); } } diff --git a/libjava/java/awt/image/ShortLookupTable.java b/libjava/java/awt/image/ShortLookupTable.java new file mode 100644 index 00000000000..223d03bf53b --- /dev/null +++ b/libjava/java/awt/image/ShortLookupTable.java @@ -0,0 +1,162 @@ +/* ShortLookupTable.java -- Java class for a pixel translation table. + Copyright (C) 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; + +/** + * ShortLookupTable represents translation arrays for pixel values. It wraps + * one or more data arrays for each layer (or component) in an image, such as + * Alpha, R, G, and B. When doing translation, the offset is subtracted from + * the pixel values to allow a subset of an array to be used. + * + * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a> + * @version 1.0 + */ +public class ShortLookupTable extends LookupTable +{ + // Array of translation tables. + private short data[][]; + + /** + * Creates a new <code>ShortLookupTable</code> instance. + * + * Offset is subtracted from pixel values when looking up in the translation + * tables. If data.length is one, the same table is applied to all pixel + * components. + * + * @param offset Offset to be subtracted. + * @param data Array of lookup tables. + * @exception IllegalArgumentException if offset < 0 or data.length < 1. + */ + public ShortLookupTable(int offset, short[][] data) + throws IllegalArgumentException + { + super(offset, data.length); + this.data = data; + } + + /** + * Creates a new <code>ShortLookupTable</code> instance. + * + * Offset is subtracted from pixel values when looking up in the translation + * table. The same table is applied to all pixel components. + * + * @param offset Offset to be subtracted. + * @param data Lookup table for all components. + * @exception IllegalArgumentException if offset < 0. + */ + public ShortLookupTable(int offset, short[] data) + throws IllegalArgumentException + { + super(offset, 1); + this.data = new short[][] {data}; + } + + /** Return the lookup tables. */ + public final short[][] getTable() + { + return data; + } + + /** + * Return translated values for a pixel. + * + * For each value in the pixel src, use the value minus offset as an index + * in the component array and copy the value there to the output for the + * component. If dest is null, the output is a new array, otherwise the + * translated values are written to dest. Dest can be the same array as + * src. + * + * For example, if the pixel src is [2, 4, 3], and offset is 1, the output + * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the + * translation arrays. + * + * @param src Component values of a pixel. + * @param dest 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]; + + if (data.length == 1) + for (int i=0; i < src.length; i++) + dst[i] = data[0][src[i] - offset]; + else + for (int i=0; i < src.length; i++) + dst[i] = data[i][src[i] - offset]; + + return dst; + } + + /** + * Return translated values for a pixel. + * + * For each value in the pixel src, use the value minus offset as an index + * in the component array and copy the value there to the output for the + * component. If dest is null, the output is a new array, otherwise the + * translated values are written to dest. Dest can be the same array as + * src. + * + * For example, if the pixel src is [2, 4, 3], and offset is 1, the output + * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the + * translation arrays. + * + * @param src Component values of a pixel. + * @param dest 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]; + + if (data.length == 1) + for (int i=0; i < src.length; i++) + dst[i] = data[0][((int)src[i]) - offset]; + else + for (int i=0; i < src.length; i++) + dst[i] = data[i][((int)src[i]) - offset]; + + return dst; + + } +} |