From: Graydon Hoare Date: Thu, 2 Sep 2004 05:10:34 +0000 (+0000) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57579172585eae4fd6f57c0dbd55ea998ddfb63f;p=gcc.git [multiple changes] 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextAreaUI.java (create): New method. * javax/swing/text/DefaultHighlighter.java (DefaultHighlightPainter.debugRect): Removed. * javax/swing/text/StyleContext.java (DEFAULT_STYLE): New field. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicLookAndFeel.java (initComponentDefaults): Add keybindings for selection.backward and selection-forward for text components. * javax/swing/plaf/basic/BasicTextUI.java (paintSafely): Paint highlight only when something is actually selected. * javax/swing/text/DefaultCaret.java (handleHighlight): New method. (setSelectionVisible): Don't do anything when nothing changes. Handle highlight. (moveDot): Reimplemented. Handle highlight. (setDot): Set mark too. Handle highlight. (getSelectionPainter): New method. * javax/swing/text/DefaultEditorKit.java (defaultActions): Added new actions for text selection. * javax/swing/text/DefaultHighlighter.java (DefaultHighlightPainter): New inner class. (DefaultPainter): New field. (paint): Implemented. * javax/swing/text/PlainView.java (paint): Don't draw background here again. * javax/swing/text/Utilities.java (getTabbedTextWidth): Use width of ' ' instead of 'm' for tabsize. (drawTabbedText): Likewise. 2004-08-31 Graydon Hoare * javax/swing/JComponent.java (resetKeyboardActions): Add null checks. 2004-08-31 Graydon Hoare * javax/swing/DefaultButtonModel.java: Skip group notification when no group is set. 2004-08-31 Graydon Hoare * javax/swing/JColorChooser.java: Make a couple inner classes static, for jikes. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (RottView.modelToView): New method. (UpdateHandler): Renamed from EventHandler. (updateHandler): Renamed from eventHandler. (modelToView): Implemented. * javax/swing/text/AbstractDocument.java (BranchElement.getElement): Return null for non-existing indeces. (BranchElement.getElementIndex): Return 0 in some corner cases. * javax/swing/text/FieldView.java (modelToView): New method. * javax/swing/text/PlainView.java (modelToView): Made public. 2004-08-31 Kim Ho * Makefile.am: New files. * Makefile.in: Regenerate. * gcj/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * java/awt/Color.java: Fix documentation. (RGBtoHSB): Use floats for conversions. * javax/swing/ButtonGroup.java: Run Jalopy. (setSelected): Reimplement. * javax/swing/DefaultButtonModel.java: Run Jalopy. (changeState): Let ButtonGroup know that the button is changing state. * javax/swing/JColorChooser.java: Implement. * javax/swing/JLabel.java: Run Jalopy. * javax/swing/JSpinner.java: Run Jalopy. (setValue): New method. * javax/swing/JTabbedPane.java: Run Jalopy. (removeTabAt): Call correct remove method. * javax/swing/SpinnerNumberModel.java: Run Jalopy. (getPreviousValue): Compare minimum value. * javax/swing/Timer.java: Run Jalopy. (run): Comment out println. * javax/swing/ToolTipManager.java: (mouseMoved): Get new tooltip text for location. * javax/swing/colorchooser/AbstractColorChooserPanel.java: Jalopy and Javadoc. * javax/swing/colorchooser/ColorChooserComponentFactory.java: Implement. * javax/swing/colorchooser/DefaultColorSelectionModel.java: Run Jalopy. (setSelectedColor): Fire ChangeEvent. * javax/swing/colorchooser/DefaultHSBChooserPanel.java: New file. Implement. * javax/swing/colorchooser/DefaultPreviewPanel.java: Ditto. * javax/swing/colorchooser/DefaultRGBChooserPanel.java: Ditto. * javax/swing/colorchooser/DefaultSwatchChooserPanel.java: Ditto. * javax/swing/plaf/basic/BasicArrowButton.java: (getArrow): Fix size of upward pointing button. * javax/swing/plaf/basic/BasicColorChooserUI.java: Implement. * javax/swing/plaf/basic/BasicSliderUI.java: (getWidthOfWidestLabel): Use preferred dimensions. (getHeightOfTallestLabel): Ditto. * javax/swing/plaf/basic/BasicSpinnerUI.java: Run Jalopy. (mousePressed): Disable changes to spinner if it is not enabled. * testsuite/Makefile.in: Regenerate. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTableHeaderUI.java, javax/swing/plaf/basic/BasicTableUI.java: Added copyright notice. 2004-08-31 Olga Rodimina * Makefile.am: Added new files. * Makefile.in: Regenerate. * javax/swing/ComboBoxEditor.java: Added javadocs. * javax/swing/ComboBoxModel.java: Likewise. * javax/swing/DefaultComboBoxModel.java: Implemented. * javax/swing/DefaultListCellRenderer.java: Added javadocs and ran through jalopy to fix formatting style. (getListCellRendererComponent): Use appropriate border if renderer has focus and use noFocusBorder when it doesn't. * javax/swing/JComboBox.java: Implemented. * javax/swing/JList.java: (locationToIndex): New Method. Implemented. (indexToLocation): New Method. * javax/swing/JPopupMenu.java: (visible): New field. (isVisible): Changed to use new field above. (setVisible): Likewise. * javax/swing/MutableComboBoxModel.java: Added javadocs. * javax/swing/plaf/basic/BasicArrowButton.java: (shadow): Changed default color to Color.gray. * javax/swing/plaf/basic/BasicComboBoxUI.java: New File. UI delegate for JComboBox. * javax/swing/plaf/basic/BasicComboPopup.java: New File. Popup menu containing list of JComboBox's items. * javax/swing/plaf/basic/BasicComboBoxEditor.java: New File. * javax/swing/plaf/basic/BasicComboBoxRenderer.java: New File. * javax/swing/plaf/basic/BasicComboBoxUI.java: New File. * javax/swing/plaf/basic/BasicComboPopup.java: New File. * javax/swing/plaf/basic/BasicPopupMenuUI.java: (popupMenuWillBecomeVisible): Set selected path to the first element only if it is of type MenuElement. Also fix formatting style. * javax/swing/plaf/basic/ComboPopup.java: Added javadocs and missing methods signatures. 2004-08-31 Michael Koch * javax/swing/text/AbstractDocument.java (createBranchElement): Use new constructor of BranchElement. (createLeafElement): Renamed arguments. (getRootElements): Implemented. (BranchElement.start): Removed. (BranchElement.end): Likewise. (BranchElement.BranchElement): Fixed arguments. (BranchElement.getEndOffset): Reimplemented. (BranchElement.getStartOffset): Likewis. * javax/swing/text/DefaultCaret.java (paint): Draw simple vertical line as caret instead of a rectangle. * javax/swing/text/JTextComponent.java (setText): Use doc directly. * javax/swing/text/PlainView.java (nextTabStop): Implemented. * javax/swing/text/Utilities.java (drawTabbedText): nextTabStop() returns an absolute x position. (getTabbedTextWidth): Likewise. 2004-08-31 Graydon Hoare * java/awt/Component.java (isFocusTraversable): Predicate on isLightweight() (setFocusable): Set isFocusTraversableOverridden. (requestFocus): Predicate peer dispatch on !isLightweight() (requestFocusInWindow): Likewise. (dispatchEventImpl): Coordinate with KeyboardFocusManager. * java/awt/Container.java (dispatchEventImpl): Predicate on event mask. (LightweightDispatcher): Remove focus machinery. * java/awt/DefaultFocusTraversalPolicy.java (accept): Expand predicate to include isFocusable(). * java/awt/DefaultKeyboardFocusManager.java: Globally change c.dispatchEvent(e) to redispatchEvent(c,e) * java/awt/KeyboardFocusManager.java (redispatchEvent): Synchronize on event to prevent feedback. * javax/swing/AbstractButton.java (ButtonFocusListener): Remove class. (init): Set focusPainted, focusable. * javax/swing/ActionMap.java (get): Check parent for null. * javax/swing/InputMap.java (get): Likewise. * javax/swing/JComponent.java (inputMap_whenFocused): New InputMap. (inputMap_whenAncestorOfFocused): Likewise. (inputMap_whenInFocusedWindow): Likewise. (getActionForKeyStroke): Rewrite. (getConditionForKeystroke): Likewise. (ActionListenerProxy): New private class. (setInputMap): Implement. (getInputMap): Likewise. (setActionMap): Likewise. (getActionMap): Likewise. (processComponentKeyEvent): New empty method. (processKeyEvent): Implement. (processKeyBinding): Likewise. (resetKeyboardActions): Rewrite. * javax/swing/KeyStroke.java: Rewrite. * javax/swing/SwingUtilities.java (notifyAction): Implement. (replaceUIActionMap): Likewise. (replaceUIInputMap): Likewise. * javax/swing/plaf/basic/BasicButtonListener.java (focusGained): Implement. (focusLost): Repaint if focusPainted(). (installKeyboardActions): Install pressed / released actions. (uninstallKeyboardActions): Implement. * javax/swing/plaf/basic/BasicButtonUI.java (focusColor): New field. (installDefaults): Load focus color, install input map. (installKeyboardActions): Implement. (uninstallKeyboardActions): Likewise. (paintFocus): Rewrite. * javax/swing/plaf/basic/BasicLookAndFeel.java (Button.focus): New default, midPurple. * javax/swing/plaf/basic/BasicTextUI.java (kit): Make static. (installUI): Get doc from kit, load defaults. (getKeymapName): Implement. (createKeymap): Likewise. (installKeyboardActions): Likewise. (getInputMap): Likewise. (getActionMap): Likewise. (createActionMap): Likewise. * javax/swing/text/AbstractDocument.java (getStartPosition): Implement. (getEndPosition): Likewise. * javax/swing/text/DefaultEditorKit.java (CopyAction): New class. (CutAction): Likewise. (DefaultKeyTypedAction): Likewise. (InsertBreakAction): Likewise. (InsertContentAction): Likewise. (InsertTabAction): Likewise. (PasteAction): Likewise. (defaultActions): New static table. (createCaret): Implement. (getActions): Likewise. * javax/swing/text/JTextComponent.java (KeymapWrapper): New private class. (KeymapActionMap): Likewise. (DefaultKeymap): New class. (keymaps): New static table. (keymap): New field. (getKeymap): Implement. (removeKeymap): Likewise. (addKeymap): Likewise. (setKeymap): Likewise. (loadKeymap): Likewise. (getActions): Likewise. (margin): New field. (JTextComponent): Build and install default keymap. * javax/swing/text/TextAction.java (textAction): Call super properly. (getTextComponent): Implement. * javax/swing/text/Utilities.java (drawTabbedText): Adjust position by ascent. 2004-08-31 David Jee PR AWT/17156 * gnu/java/awt/peer/gtk/GtkMenuItemPeer.java (setEnabled): Make it a native method. * java/awt/DefaultKeyboardFocusManager.java (postProcessKeyEvent): Only post event if the menu item is active. * java/awt/MenuItem.java: Private field 'enabled' should be true by default. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c (setEnabled): New function. 2004-08-31 David Jee PR AWT/17059 * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java (nativeSetHelpMenu): New native method declaration. (addHelpMenu): Call nativeSetHelpMenu(). (addMenu): Remove. * java/awt/MenuBar.java (setHelpMenu): Call addNotify() on the new help menu. (add): Call addNotify() on the new menu. (addNotify): Set the help menu if one exists. * java/awt/peer/MenuBarPeer.java (addMenu): Remove. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c (nativeSetHelpMenu): New method. 2004-08-31 Graydon Hoare * Makefile.am: Add new files. * Makefile.in: Regenerate. * javax/swing/Box.java: Fix setting of layout in ctor. * javax/swing/JScrollPane.java: Scroll headers as well. * javax/swing/JTable.java: Reimplement. * javax/swing/JViewPort.java: Only add non-null children. * javax/swing/ScrollPaneLayout.java: Correct header calculations. * javax/swing/Timer.java: Fix stopping null waker. * javax/swing/plaf/basic/BasicTableHeaderUI.java: New file. * javax/swing/plaf/basic/BasicTableUI.java: New file. * javax/swing/table/DefaultTableCellRenderer.java: Configure. * javax/swing/table/DefaultTableColumnModel.java: Flesh out. * javax/swing/table/DefaultTableModel.java: Clean up. * javax/swing/table/JTableHeader.java: Implement. 2004-08-31 Mark Wielaard * javax/swing/JSpinner.java (getChangeListeners): Remove double semi-colon. 2004-08-31 Mark Wielaard * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c: Declare variables at top of functions/block. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise. 2004-08-31 Mark Wielaard * java/lang/Rectangle.java (intersects): Check r.width and r.height first. 2004-08-31 Michael Koch * javax/swing/text/PlainView.java (selectedColor): New field. (unselectedColor): Likewise. (font): Likewise. (updateMetrics): New method. (lineToRect): Likewise. (modelToView): Likewise. (drawSelectedText): Use color from JTextComponent ad draw with Utilities class. (drawUnselectedText): Likewise. (paint): Initialize helper fields. * javax/swing/text/View.java (getChildAllocation): New method. (getViewIndex): Likewise. (getToolTipText): Likewise. 2004-08-31 Michael Koch * javax/swing/text/Utilities.java (drawTabbedText): Reimplemented. (getTabbedTextWidth): Likewise. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (installDefaults): Install caret and highlighter. (modelToView): Use Bias.Forward when calling sibling. * javax/swing/text/AbstractDocument.java (ElementEdit): Implements DocumentEvent.ElementChange. (ElementEdit.ElementEdit): New method. (ElementEdit.getChildrenAdded): Likewise. (ElementEdit.getChildrenRemoved): Likewise. (ElementEdit.getElement): Likewise. (ElementEdit.getIndex): Likewise. * javax/swing/text/DefaultCaret.java (color): Removed. (textComponent): Renamed from parent, made private. (selectionVisible): Renamed from vis_sel, made private. (blinkRate): Renamed from blink, made private. (magicCaretPosition): Renamed from magic, made private. (visible): Renamed from vis, made private. (dot): Made private. (mark): Likewise. (deinstall): Remove as MouseMotionListener. (install): Initialize textComponent first. Add as MouseMotionListener. (paint): Reimplemented. * javax/swing/text/JTextComponent.java (setCaret): Deinstall old caret, install new one and fire property change after setting property. (setHighlighter): Deinstall old highlighter, install new one and fire property change after setting property. (setCaretColor): Fire property change after setting property. (setDisabledTextColor): Likewise. (setSelectedTextColor): Likewise. (setSelectionColor): Likewise. (modelToView): New method. 2004-08-31 Michael Koch * javax/swing/text/AbstractDocument.java (getText): Simplified. * javax/swing/text/Segment.java (current): New field. (current): Reimplemented. (first): Likewise. (getIndex): Likewise. (last): Likewise. (next): Likewise. (previous): Likewise. (setIndex): Likewise. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicButtonUI.java (defaultTextIconGap): Made protected. (defaultTextShiftOffset): Likewise. (textShiftOffset): New field. (clearTextShiftOffset): New method. (getTextShiftOffset): Likewise. (setTextShiftOffset): Likewise. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (installUI): Add eventHandler as property listener. (uninstallUI): remove eventHandler as propert listener. (installDefaults): Added comment. (installListeners): Likewise. (installKeyboardActions): Likewise. (uninstallDefaults): Likewise. (uninstallListeners): Likewise. (uninstallKeyboardActions): Likewise. 2004-08-31 Michael Koch * javax/swing/text/AbstractDocument.java: Fixed some typos in comments. (insertString): Reimplemented. (remove): Likewise. (replace): New method. (children): Dont use fully qualified class name. (DefaultDocumentEvent.offset): Renamed from off. (DefaultDocumentEvent.length): Renamed from len. (DefaultDocumentEvent.type): New field. (DefaultDocumentEvent.DefaultDocumentEvent): New constructor. (DefaultDocumentEvent.getType): Implemented. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (RootView.textComponent): Removed. (RootView.RootView): Don't initialize textComponent. (RootView.getViewFactory): New method. (EventHandler): New inner class. (rootView): Initialize at instance creation. (eventHandler): New field. (installUI): Don't create view hierarchy directly, call modelChanged() instead. (modelChanged): New method. * javax/swing/text/JTextComponent.java (setDocument): Fire property change event. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicTextUI.java (RootView.paint): Removed debug output. (paintSafely): Draw highlighter before text. (paintBackground): Use background color of text component. * javax/swing/plaf/basic/BasicToggleButtonUI.java: Reformatted. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicToolBarUI.java (BasicToolBarUI): Fixed arguments for constructor. (createUI): Fixed creation of object. 2004-08-31 Michael Koch * javax/swing/DefaultListSelectionModel.java (fireValueChanged): Renamed from fireSelectionValueChanged, made protected. 2004-08-31 Michael Koch * javax/swing/text/TabSet.java (TabSet): Implements java.io.Serializable. * javax/swing/text/TabStop.java (TabStop): Implements java.io.Serializable. (TabStop): Made public. 2004-08-31 Michael Koch * javax/swing/JComponent.java (setUI): Fire PropertyChange. * javax/swing/JLabel.java (text): Renamed from labelText. (horizontalAlignment): New default vlaue. (icon): Renamed from activeIcon. (displayedMnemonic): Renamed from mnemonicKey, added default value. (displayedMnemonicIndex): Renamed from underlineChar. (setDisplayedMnemonic): Reimplemented. * javax/swing/JRadioButton.java (JRadioButton): New constructors. * javax/swing/JTextField.java (JTextField): Throw exception if colums < 0, initialitialz this.columns directly and initialize document with text conditionally. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicFormattedTextFieldUI.java, javax/swing/plaf/basic/BasicPasswordFieldUI.java, javax/swing/plaf/basic/BasicTextAreaUI.java: New files. * javax/swing/text/FieldView.java (paint): Just call super method for now. * Makefile.am: Added new files. * Makefile.in: Regenerated. 2004-08-31 Ka-Hing Cheung * javax/swing/AbstractSpinnerModel.java, javax/swing/JSpinner.java, javax/swing/SpinnerNumberModel.java, javax/swing/plaf/basic/BasicSpinnerUI.java: New files. * javax/swing/plaf/basic/BasicLookAndFeel.java (initClassDefaults): Added defaults for BasicSpinnerUI. 2004-08-31 Michael Koch * Makefile.am: Added new files. * Makefile.in: Regenerated. 2004-08-31 Michael Koch * javax/swing/TransferHandler.java, javax/swing/plaf/basic/ComboPopup.java: New files * Makefile.am: Added javax/swing/TransferHandler.java and javax/swing/plaf/basic/ComboPopup.java * Makefile.in: Regenerated. 2004-08-31 Roman Kennke * javax/swing/text/Utilities.java: New file. 2004-08-31 Michael Koch * Makefile.am: Added javax/swing/text/Utilities.java. * Makefile.in: Regenerated. 2004-08-31 Graydon Hoare * javax/swing/text/SimpleAttributeSet.java: New file. * javax/swing/text/StyleConstants.java: New file. * javax/swing/text/StyleContext.java: New file. * javax/swing/text/TabSet.java: New file. * javax/swing/text/TabStop.java: New file. * javax/swing/text/AbstactDocument.java: (AbstractElement): Implement attribute support. * javax/swing/text/AttributeSet.java (NameAttribute): New static field. (ResolveAttribute): New static field. * Makefile.am: Update for new files. * Makefile.in: Regenerate. 2004-08-31 Craig Black * gnu/java/awt/peer/gtk/GdkGraphics.java (drawImage): Add support for scaling pixmaps. * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (copyAndScalePixmap): New native method. 2004-08-31 Thomas Fitzsimmons PR AWT/16121 * jni/gtk-peer/gthread-jni.c: Include stdio.h. Eliminate type-punning compiler warnings using unions. (throw): Replace bzero with memset. 2004-08-31 Andreas Tobler Thomas Fitzsimmons * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: Move NSA_PB macros to gtkpeer.h. Include gtkpeer.h. * jni/gtk-peer/gtkpeer.h: Move NSA_PB macros here. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (nativeSetIconImageFromDecoder): Use NSA_GET_PB_PTR macro. 2004-08-31 Mark Wielaard * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: #include gdk.h, not gtk.h. #include jni.h, native_state.h, string.h and stdlib.h, not gtkpeer.h. (*vm): New static variable. (areaPreparedID): Make static. (areaUpdatedID): Likewise. (area_prepared): Get and use JNIEnv through stored JavaVM *vm. (area_prepared): Likewise. (area_updated): Likewise. (closed): Likewise. (initStaticState): Initialize *vm javaVM. (pumpBytes): Use given env, not global gdk_env. 2004-08-31 Mark Wielaard * java/awt/geom/CubicCurve2D.java (solveCubic): Removed duplicate comments. 2004-08-31 Sven de Marothy * java/awt/geom/CubicCurve2D.java: Reindent. (contains): Implemented. (intersects): Implemented. * java/awt/geom/QuadCurve2D.java: Likewise. * java/awt/geom/GeneralPath.java: Reindent and document. Fully (re)implemented using separate xpoints and ypoints float[] coords. * java/awt/geom/RoundRectangle2D.java: Several bugfixes (Bug #6007). 2004-08-31 Michael Koch * javax/swing/JMenuItem.java (getMenuDragMouseListeners): New method. (getMenuKeyListeners): Likewise. 2004-08-31 Michael Koch * javax/swing/AbstractButton.java (model): Made protected. (actionListener): Likewise. (changeListener): Likewise. (itemListener): Likewise. (multiClickThreshhold): New field. (getActionListeners): New method. (getChangeListeners): Likewise. (getItemListeners): Likewise. (fireItemStateChanged): Simplified implementation. (fireActionPerformed): Likewise. (fireStateChanged): Likewise. (getMultiClickThreshhold): New method. (setMultiClickThreshhold): Likewise. 2004-08-31 Tom Tromey * java/awt/image/Kernel.java (clone): Use super.clone(). 2004-08-31 David Jee PR AWT/16682 * gnu/java/awt/peer/gtk/GtkFramePeer.java (nativeSetIconImage): Rename to nativeSetIconImageFromDecoder. (nativeSetIconImageFromData): New native method declaration. (setIconImage): Handle images not produced from GdkPixbufDecoder. * gnu/java/awt/peer/gtk/GtkImage.java (getPixelCache): New method. (getColorModel): New method. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (nativeSetIconImage): Rename to nativeSetIconImageFromDecoder. (free_pixbuf_data): New helper function. (nativeSetIconImageFromData): New function. 2004-08-31 Graydon Hoare PR SWING/16576 * javax/swing/JLayeredPane.java (setLayer): Permit changing layer after addition. (setPosition): Permit over-length positions. (layerToRange): Compare intValue()s. * javax/swing/Box.java (createHorizontalBox): Implement. (createRigidArea): Likewise. (createVerticalBox): Likewise. 2004-08-31 Kim Ho * java/awt/Component.java: (processMouseEvent): Consume event after listeners process it. (processMouseMotionEvent): ditto. (processMouseWheelEvent): ditto. * java/awt/Container.java: (acquireComponentForMouseEvent): Do not dispatch to events that have been removed from the Container. (handleEvent): Consume the MouseEvents. * javax/swing/RepaintManager.java: (paintDirtyRegions): Do not add to list of damaged areas if the component has no root. 2004-08-31 Michael Koch * javax/swing/plaf/basic/BasicMenuItemUI.java: Clean ip imports. 2004-08-31 Mark Wielaard * gnu/java/awt/peer/gtk/GtkToolkit.java (getFontPeer): Don't return null when a MissingResourceException is thrown. Should never happen. 2004-08-31 Mark Wielaard * java/awt/EventQueue.java (postEvent): Throw NullPointerException when argument is null. 2004-08-31 Mark Wielaard * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilter): Define hid at start of function. (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter): Likewise. 2004-08-31 Mark Wielaard * gnu/java/awt/EmbeddedWindow.java: Reindent. * javax/swing/JButton.java: Reindent. * javax/swing/JCheckBox.java: Reindent. 2004-08-31 Mark Wielaard * Makefile.am (gtk_c_source_files): Added jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c. (gtk_awt_peer_sources): Added gnu/java/awt/peer/gtk/GThreadMutex.java and gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java. * Makefile.in: Regenerated. 2004-08-31 Archie Cobbs * jni/gtk-peer/gthread-jni.c: don't #include nonexistent files 2004-08-31 Steven Augart * jni/gtk-peer/gthread-jni.c (c-font-lock-extra-types): Added jfieldID, jmethodID. 2004-08-31 Mark Wielaard * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): Initialize gdk_env before calling any gdk or gtk function. * gnu/java/awt/peer/gtk/GtkMainThread.java (gtkInitCalled): New field. (GtkMainThread): Call wait() in while loop waiting for gtkInitCalled. (run): Set gtkInitCalled. 2004-08-31 Steven Augart * gnu/java/awt/peer/gtk/GtkMainThread.java (run): Pass the value of the gnu.classpath.awt.gtk.portable.native.sync system property to C. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): New argument, portableNativeSync. Delegate PORTABLE_NATIVE_SYNC work to init_glib_threads. (init_glib_threads): New function. 2004-08-31 Mark Wielaard * jni/gtk-peer/gthread-jni.c: Define MIN_, MAX_ and NORM_ PRIORITY when not already defined in header file. 2004-08-31 Mark Wielaard * jni/gtk-peer/gthread-jni.c (setup_cache): Call ExceptionOccurred, not ExceptionCheck, when we don't have JNI 1.2. 2004-08-31 Steven Augart * gnu/native/jni/gtk-peer/gthread-jni.c: Indentation fixes. Implemented missing functions for GTK2. Added error handling. Renamed static functions out of the g_ namespace. Added TRACE_API_CALLS, EXPLAIN_TROUBLE, EXPLAIN_BROKEN, EXPLAIN_BADLY_BROKEN, and DELETE_LOCAL_REFS options. Rewrote global-reference code. Eliminated cascading errors. (mutex_trylock_jni_impl) Fully implemented. (cond_timed_wait_jni_impl) Went from millisecond to microsecond resolution. (setup_cache) New function. (mutex_cond_wait_jni_impl, mutex_cond_timed_wait_jni_impl) Fixed bug where they were not unlocking the GMutex associated with the condition variable during the wait on that condition variable. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c, native/jni/gtk-peer/gthread-jni.c, native/jni/gtk-peer/gthread-jni.h (g_thread_jni_functions): Renamed to ... (portable_native_sync_jni_functions): this name. (gdk_vm): Renamed to... (the_vm): this name. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c (gdk_vm): Removed duplicate definition. (gtkInit): Removed stray message to stdout. (gtkInit): Use g_malloc and g_free instead of malloc and free. (gtkInit): Fix a const assignment bug. (gtkInit): Simplified code. * gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c, native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h, gnu/java/awt/peer/gtk/GThreadMutex.java: New files. 2004-08-31 Mark Wielaard * javax/swing/Box.java: Put FIXME comment above class declaration. * javax/swing/JButton.java: Remove illegal L&F HTML from comments. * javax/swing/JCheckBox.java: Likewise. * javax/swing/JDialog.java: Likewise. * javax/swing/JRadioButton.java: Likewise. * javax/swing/JToggleButton.java: Likewise. * javax/swing/UIManager.java: Likewise. * javax/swing/border/TitledBorder.java: Likewise. * javax/swing/plaf/basic/BasicLabelUI.java: Likewise. * javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise. * javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java: Likewise. * javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise. * javax/swing/plaf/basic/BasicScrollBarUI.java: Likewise. * javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise. * javax/swing/text/JTextComponent.java: Likewise. 2004-08-31 David Jee PR AWT/16682 * gnu/java/awt/peer/gtk/GtkFramePeer.java (setIconImage): Add a FIXME for unhandled cases. 2004-08-31 Thomas Fitzsimmons PR AWT/16040 * gnu/awt/LightweightRedirector.java: Call getModifiersEx, not getModifiers. Replace old button masks with new ones. * gnu/awt/xlib/XEventLoop.java: Likewise. * gnu/java/awt/peer/gtk/GtkButtonPeer.java: Likewise. * gnu/java/awt/peer/gtk/GtkComponentPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise. * gnu/java/awt/peer/gtk/GtkListPeer.java: Likewise. * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Likewise. * java/awt/AWTKeyStroke.java: Remove old modifier masks. * java/awt/Component.java: Replace old modifier masks with new ones. * java/awt/Container.java: Call getModifiersEx, not getModifiers. * java/awt/DefaultKeyboardFocusManager.java: Likewise. Remove old modifier masks. * javax/swing/JMenuItem.java: Replace old button masks with new ones. * javax/swing/KeyStroke.java: Call getModifiersEx, not getModifiers. * javax/swing/SwingUtilities.java: Likewise. * javax/swing/plaf/basic/BasicButtonListener.java: Likewise. * javax/swing/plaf/basic/BasicInternalFrameUI.java: Likewise. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Replace old mask macros with new ones. * jni/gtk-peer/gtkpeer.h: Replace old button and modifier mask macros with new ones representing new masks. 2004-08-31 Craig Black * gnu/java/awt/peer/gtk/GdkGraphics.java (drawRoundRect): Implemented. (fillRoundRect): Implemented. * gnu/java/awt/peer/gtk/GdkGraphics2D.java (drawRoundRect): Reimplemented to match GdkGraphics. (fillRoundRect): Reimplemented to match GdkGraphics. 2004-08-31 Mark Wielaard * Makefile.in: Regenerated. 2004-08-31 Michael Koch * gnu/java/awt/EmbeddedWindow.java (addNotify): Use AccessController to allow execution of privileged code. 2004-08-31 Michael Koch * gnu/java/awt/EmbeddedWindow.java (static): Removed. (addNotify): Set peer via reflection. (setWindowPeer): Removed. * gnu/java/awt/natEmbeddedWindow.cc: Removed. * Makefile.am (nat_source_files): Removed gnu/java/awt/natEmbeddedWindow.cc. 2004-08-31 Bryce McKinlay * Makefile.am: Add gnu/java/security/action/GetPropertyAction.java and gnu/java/security/action/SetAccessibleAction.java. 2004-08-31 Bryce McKinlay * gnu/java/security/action/GetPropertyAction.java (setParameters): Renamed from 'setName'. New 2-argument form with default value. (run): Pass default 'value' parameter to System.getProperty(). * gnu/java/security/action/SetAccessibleAction.java: Fix javadoc typos. 2004-08-31 Bryce McKinlay * gnu/java/security/action/GetPropertyAction.java: New class. * gnu/java/security/action/SetAccessibleAction.java: New class. 2004-08-31 David Jee * gnu/java/awt/peer/gtk/GtkFramePeer.java (setIconImage): Check if image is null. 2004-08-31 David Jee * gnu/java/awt/peer/gtk/GtkFramePeer.java (create): Set the icon image. (nativeSetIconImage): New native method declaration. (setIconImage): Implement. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (nativeSetIconImage): New function. 2004-08-31 Dalibor Topic * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c (filenameFilterCallback): Declare local variable accepted before use. 2004-08-31 Dalibor Topic * gnu/java/awt/ComponentDataBlitOp.java: Cleaned up imports. 2004-08-31 Tom Tromey * gnu/java/awt/peer/GLightweightPeer.java, gnu/java/awt/peer/gtk/GdkGraphics2D.java, gnu/java/awt/peer/gtk/GtkComponentPeer.java, javax/swing/JScrollPane.java: Removed redundant imports. 2004-08-31 David Jee * java/awt/DefaultKeyboardFocusManager.java (postProcessKeyEvent): Only activate MenuShortcuts on KEY_PRESSED event. Fix shift modifier checking. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c (accel_attach): Remove. (setupAccelGroup): Remove calls to accel_attach. 2004-08-31 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GtkArg.java: Remove file. * gnu/java/awt/peer/gtk/GtkArgList.java: Remove file. * Makefile.am (gtk_awt_peer_sources): Remove GtkArg.java and GtkArgList.java. (gtk_c_files): Use CAIRO_CFLAGS and PANGOFT2_CFLAGS, not _LIBS. * Makefile.in: Regenerate. * gnu/java/awt/peer/gtk/GtkButtonPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c (create(String)): New method. (create): Call new create method. (getArgs): Remove method. * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c (nativeCreate): Rename to create. (gtkSetLabel): Rename to gtkButtonSetLabel. (gtkToggleButtonSetActive): New method. (create): Call gtkToggleButtonSetActive and gtkButtonSetLabel. (setState): Replace set call with gtkToggleButtonSetActive. (setLabel): Replace gtkSetLabel call with gtkButtonSetLabel. (getArgs): Remove method. * gnu/java/awt/peer/gtk/GtkComponentPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (gtkWidgetSetSensitive): New method. (gtkWidgetSetParent): Likewise. (GtkComponentPeer): Call setParent, setComponentBounds and setVisibleAndEnabled. (setParent): New method. (setComponentBounds): New method. (setVisibleAndEnabled): New method. (setEnabled): Call gtkWidgetSetSensitive. (getArgs): Remove method. Remove all set methods. * gnu/java/awt/peer/gtk/GtkDialogPeer.java (create): Call gtkWindowSetModal, setTitle and setResizable. (getArgs): Remove method. * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java (setComponentBounds): New method. * gnu/java/awt/peer/gtk/GtkFramePeer.java (setResizable): Replace set call with gtkWindowSetResizable. (getArgs): Remove method. (create): Call setTitle and setResizable. * gnu/java/awt/peer/gtk/GtkWindowPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (gtkWindowSetTitle): New method. (gtkWindowSetResizable): New method. (gtkWindowSetModal): New method. (setParent): New method. (setVisibleAndEnabled): New method. (getArgs): Remove method. (setTitle): Call gtkWindowSetTitle. (setResizable): Call gtkWindowSetResizable. * jni/gtk-peer/gtkpeer.h [DEBUG_LOCKING]: New define to turn on and off locking instrumentation. 2004-08-31 Kim Ho * Makefile.am: Add new file. * Makefile.in: Regenerate. * gcj/Makefile.in: Regenerate * include/Makefile.in: * java/awt/Container.java: (acquireComponentForMouseEvent): Respect the event mask when looking for candidate. * javax/swing/JComponent.java: Remove toolTip field. (createToolTip): Create a tooltip on demand. (setToolTipText): Register with the ToolTipManager. (getToolTipText(MouseEvent)): Return getToolTipText(). * javax/swing/JToolTip.java: Implement. * javax/swing/Timer.java: Jalopy. (restart): Call stop, then start. (stop): Interrupt the timer rather than wait for the timer to come to a stop naturally. * javax/swing/ToolTipManager.java: Implement. * javax/swing/plaf/basic/BasicLookAndFeel.java: Change ToolTip.background color. * javax/swing/plaf/basic/BasicToolTipUI.java: Implement. * testsuite/Makefile.in: Regenerate 2004-08-31 Jerry Quinn * java/awt/image/DirectColorModel.java (DirectColorModel): Fix constructor param comments. 2004-08-31 Thomas Fitzsimmons * java/awt/Component.java: Document AWT 1.0 event handler methods. 2004-08-31 Roman Kennke * javax/swing/Box.java: (createGlue): Implemented (createHorizontalGlue): Implemented (createHorizontalStrut): Implemented (createVerticalGlue): Implemented (createVerticalStrut): Implemented 2004-08-31 David Jee * gnu/java/awt/peer/gtk/GtkChoicePeer.java (GtkChoicePeer): Do not automatically select first item. (getHistory): Remove. (nativeGetSelected): New method. (nativeRemoveAll): New method. (add): Use nativeGetSelected() instead of getHistory(). (remove): Likewise. (removeAll): Call nativeRemoveAll(). * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c (create): Migrate to GtkComboBox. (append): Likewise. (nativeAdd): Likewise. (nativeRemove): Likewise. (select): Likewise. (nativeRemoveAll): New method. (nativeGetSelected): New method. (selection_changed): New method. (getHistory): Remove. (item_activate): Remove. (item_removed): Remove. (connect_choice_item_selectable_hook): Remove. 2004-08-31 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (create): Use tf variable in setEditable call. * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c (gtkWidgetSetBackground): New method. (gtkWidgetSetForeground): Likewise. (create): Set peer's editable state based on awtComponent's. * java/awt/Button.java (Button()): Use empty string rather than null in no-label constructor. 2004-08-31 Roman Kennke * javax/swing/BoxLayout.java: Reimplement. 2004-08-31 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GdkGraphics.java, gnu_java_awt_peer_gtk_GdkGraphics.c (initState(GtkComponentPeer)): Don't return array of colour values. (GdkGraphics(int,int)): Set default font to size 12. (GdkGraphics(GtkComponentPeer)): Set graphics colour to component's foreground colour. * gnu/java/awt/peer/gtk/GdkGraphics2D.java, gnu_java_awt_peer_gtk_GdkGraphics2D.c (initState(GtkComponentPeer)): Don't return array of colour values. (GdkGraphics2D(GtkComponentPeer)): Set foreground and background colours to component's colours. (current_colors_of_widget): Remove function. * gnu/java/awt/peer/gtk/GtkOffScreenImage.java (getGraphics): Return a new graphics object. * java/awt/Font.java (toString): Fix format. * java/awt/Graphics.java (toString): Likewise. 2004-08-31 Craig Black * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c (addTearOff): New function. * gnu/java/awt/peer/gtk/GtkMenuPeer.java (addTearOff): New native method. (init): Call addTearOff() when menu.isTearOff(). 2004-08-31 Bryce McKinlay * gnu/java/awt/ClasspathToolkit.java (createImageProducer): New. Default implementation. * gnu/java/awt/peer/gtk/GtkToolkit.java (createImageProducer): New. Implement using GdkPixbufDecoder. 2004-08-31 David Jee * gnu/java/awt/peer/gtk/GtkComponentPeer.java (GtkComponentPeer): Use gtkWidgetGetPreferredDimensions() for setting the size of GtkFileDialogPeers. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c (gtkWidgetGetPreferredDimensions): For widgets extending GtkWindow, use their default sizes rather than their natural requisitions. 2004-08-31 Michael Koch * javax/swing/JFormattedTextField.java (JFormattedTextField): Implemented. * javax/swing/text/DefaultEditorKit.java (BeepAction): New inner class. * javax/swing/text/Segment.java (partialReturn): New field. (setPartialReturn): New method. (isPartialReturn): Likewise. * javax/swing/text/View.java (createFragment): Fixed typo. (getStartOffset): New method. (getEndOffset): Likewise. 2004-08-31 Michael Koch * javax/swing/table/DefaultTableColumnModel.java (serialVersionUID): Made private. (listenerList): Initialize. (changeEvent): Initialize. * javax/swing/table/JTableHeader.java (JTableHeader): New constructors. (createDefaultColumnModel): New method. * javax/swing/table/TableColumn.java (setHeaderRenderer): Simplified code. (setCellRenderer): Likewise. (setWidth): Likewise. From-SVN: r86956 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 9cf9a202c1b..f717644a896 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,1174 @@ +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextAreaUI.java + (create): New method. + * javax/swing/text/DefaultHighlighter.java + (DefaultHighlightPainter.debugRect): Removed. + * javax/swing/text/StyleContext.java + (DEFAULT_STYLE): New field. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicLookAndFeel.java + (initComponentDefaults): Add keybindings for selection.backward and + selection-forward for text components. + * javax/swing/plaf/basic/BasicTextUI.java + (paintSafely): Paint highlight only when something is actually + selected. + * javax/swing/text/DefaultCaret.java + (handleHighlight): New method. + (setSelectionVisible): Don't do anything when nothing changes. + Handle highlight. + (moveDot): Reimplemented. Handle highlight. + (setDot): Set mark too. Handle highlight. + (getSelectionPainter): New method. + * javax/swing/text/DefaultEditorKit.java + (defaultActions): Added new actions for text selection. + * javax/swing/text/DefaultHighlighter.java + (DefaultHighlightPainter): New inner class. + (DefaultPainter): New field. + (paint): Implemented. + * javax/swing/text/PlainView.java + (paint): Don't draw background here again. + * javax/swing/text/Utilities.java + (getTabbedTextWidth): Use width of ' ' instead of 'm' for tabsize. + (drawTabbedText): Likewise. + +2004-08-31 Graydon Hoare + + * javax/swing/JComponent.java + (resetKeyboardActions): Add null checks. + +2004-08-31 Graydon Hoare + + * javax/swing/DefaultButtonModel.java: + Skip group notification when no group is set. + +2004-08-31 Graydon Hoare + + * javax/swing/JColorChooser.java: + Make a couple inner classes static, for jikes. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextUI.java + (RottView.modelToView): New method. + (UpdateHandler): Renamed from EventHandler. + (updateHandler): Renamed from eventHandler. + (modelToView): Implemented. + * javax/swing/text/AbstractDocument.java + (BranchElement.getElement): Return null for non-existing indeces. + (BranchElement.getElementIndex): Return 0 in some corner cases. + * javax/swing/text/FieldView.java + (modelToView): New method. + * javax/swing/text/PlainView.java + (modelToView): Made public. + +2004-08-31 Kim Ho + + * Makefile.am: New files. + * Makefile.in: Regenerate. + * gcj/Makefile.in: Regenerate. + * include/Makefile.in: Regenerate. + * java/awt/Color.java: Fix documentation. + (RGBtoHSB): Use floats for conversions. + * javax/swing/ButtonGroup.java: Run Jalopy. + (setSelected): Reimplement. + * javax/swing/DefaultButtonModel.java: Run Jalopy. + (changeState): Let ButtonGroup know that the button + is changing state. + * javax/swing/JColorChooser.java: Implement. + * javax/swing/JLabel.java: Run Jalopy. + * javax/swing/JSpinner.java: Run Jalopy. + (setValue): New method. + * javax/swing/JTabbedPane.java: Run Jalopy. + (removeTabAt): Call correct remove method. + * javax/swing/SpinnerNumberModel.java: Run Jalopy. + (getPreviousValue): Compare minimum value. + * javax/swing/Timer.java: Run Jalopy. + (run): Comment out println. + * javax/swing/ToolTipManager.java: + (mouseMoved): Get new tooltip text for location. + * javax/swing/colorchooser/AbstractColorChooserPanel.java: + Jalopy and Javadoc. + * javax/swing/colorchooser/ColorChooserComponentFactory.java: + Implement. + * javax/swing/colorchooser/DefaultColorSelectionModel.java: + Run Jalopy. + (setSelectedColor): Fire ChangeEvent. + * javax/swing/colorchooser/DefaultHSBChooserPanel.java: + New file. Implement. + * javax/swing/colorchooser/DefaultPreviewPanel.java: + Ditto. + * javax/swing/colorchooser/DefaultRGBChooserPanel.java: + Ditto. + * javax/swing/colorchooser/DefaultSwatchChooserPanel.java: + Ditto. + * javax/swing/plaf/basic/BasicArrowButton.java: + (getArrow): Fix size of upward pointing button. + * javax/swing/plaf/basic/BasicColorChooserUI.java: + Implement. + * javax/swing/plaf/basic/BasicSliderUI.java: + (getWidthOfWidestLabel): Use preferred dimensions. + (getHeightOfTallestLabel): Ditto. + * javax/swing/plaf/basic/BasicSpinnerUI.java: + Run Jalopy. + (mousePressed): Disable changes to spinner if it is not enabled. + * testsuite/Makefile.in: Regenerate. + + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTableHeaderUI.java, + javax/swing/plaf/basic/BasicTableUI.java: + Added copyright notice. + +2004-08-31 Olga Rodimina + + * Makefile.am: Added new files. + * Makefile.in: Regenerate. + * javax/swing/ComboBoxEditor.java: Added javadocs. + * javax/swing/ComboBoxModel.java: Likewise. + * javax/swing/DefaultComboBoxModel.java: Implemented. + * javax/swing/DefaultListCellRenderer.java: Added javadocs + and ran through jalopy to fix formatting style. + (getListCellRendererComponent): Use appropriate border + if renderer has focus and use noFocusBorder when it doesn't. + * javax/swing/JComboBox.java: Implemented. + * javax/swing/JList.java: + (locationToIndex): New Method. Implemented. + (indexToLocation): New Method. + * javax/swing/JPopupMenu.java: + (visible): New field. + (isVisible): Changed to use new field above. + (setVisible): Likewise. + * javax/swing/MutableComboBoxModel.java: Added javadocs. + * javax/swing/plaf/basic/BasicArrowButton.java: + (shadow): Changed default color to Color.gray. + * javax/swing/plaf/basic/BasicComboBoxUI.java: New File. + UI delegate for JComboBox. + * javax/swing/plaf/basic/BasicComboPopup.java: New File. + Popup menu containing list of JComboBox's items. + * javax/swing/plaf/basic/BasicComboBoxEditor.java: New File. + * javax/swing/plaf/basic/BasicComboBoxRenderer.java: New File. + * javax/swing/plaf/basic/BasicComboBoxUI.java: New File. + * javax/swing/plaf/basic/BasicComboPopup.java: New File. + * javax/swing/plaf/basic/BasicPopupMenuUI.java: + (popupMenuWillBecomeVisible): Set selected path to the first + element only if it is of type MenuElement. Also fix formatting + style. + * javax/swing/plaf/basic/ComboPopup.java: Added javadocs and missing + methods signatures. + +2004-08-31 Michael Koch + + * javax/swing/text/AbstractDocument.java + (createBranchElement): Use new constructor of BranchElement. + (createLeafElement): Renamed arguments. + (getRootElements): Implemented. + (BranchElement.start): Removed. + (BranchElement.end): Likewise. + (BranchElement.BranchElement): Fixed arguments. + (BranchElement.getEndOffset): Reimplemented. + (BranchElement.getStartOffset): Likewis. + * javax/swing/text/DefaultCaret.java + (paint): Draw simple vertical line as caret instead of a rectangle. + * javax/swing/text/JTextComponent.java + (setText): Use doc directly. + * javax/swing/text/PlainView.java + (nextTabStop): Implemented. + * javax/swing/text/Utilities.java + (drawTabbedText): nextTabStop() returns an absolute x position. + (getTabbedTextWidth): Likewise. + +2004-08-31 Graydon Hoare + + * java/awt/Component.java + (isFocusTraversable): Predicate on isLightweight() + (setFocusable): Set isFocusTraversableOverridden. + (requestFocus): Predicate peer dispatch on !isLightweight() + (requestFocusInWindow): Likewise. + (dispatchEventImpl): Coordinate with KeyboardFocusManager. + * java/awt/Container.java + (dispatchEventImpl): Predicate on event mask. + (LightweightDispatcher): Remove focus machinery. + * java/awt/DefaultFocusTraversalPolicy.java + (accept): Expand predicate to include isFocusable(). + * java/awt/DefaultKeyboardFocusManager.java: + Globally change c.dispatchEvent(e) to redispatchEvent(c,e) + * java/awt/KeyboardFocusManager.java + (redispatchEvent): Synchronize on event to prevent feedback. + * javax/swing/AbstractButton.java + (ButtonFocusListener): Remove class. + (init): Set focusPainted, focusable. + * javax/swing/ActionMap.java (get): Check parent for null. + * javax/swing/InputMap.java (get): Likewise. + * javax/swing/JComponent.java + (inputMap_whenFocused): New InputMap. + (inputMap_whenAncestorOfFocused): Likewise. + (inputMap_whenInFocusedWindow): Likewise. + (getActionForKeyStroke): Rewrite. + (getConditionForKeystroke): Likewise. + (ActionListenerProxy): New private class. + (setInputMap): Implement. + (getInputMap): Likewise. + (setActionMap): Likewise. + (getActionMap): Likewise. + (processComponentKeyEvent): New empty method. + (processKeyEvent): Implement. + (processKeyBinding): Likewise. + (resetKeyboardActions): Rewrite. + * javax/swing/KeyStroke.java: Rewrite. + * javax/swing/SwingUtilities.java + (notifyAction): Implement. + (replaceUIActionMap): Likewise. + (replaceUIInputMap): Likewise. + * javax/swing/plaf/basic/BasicButtonListener.java + (focusGained): Implement. + (focusLost): Repaint if focusPainted(). + (installKeyboardActions): Install pressed / released actions. + (uninstallKeyboardActions): Implement. + * javax/swing/plaf/basic/BasicButtonUI.java + (focusColor): New field. + (installDefaults): Load focus color, install input map. + (installKeyboardActions): Implement. + (uninstallKeyboardActions): Likewise. + (paintFocus): Rewrite. + * javax/swing/plaf/basic/BasicLookAndFeel.java + (Button.focus): New default, midPurple. + * javax/swing/plaf/basic/BasicTextUI.java + (kit): Make static. + (installUI): Get doc from kit, load defaults. + (getKeymapName): Implement. + (createKeymap): Likewise. + (installKeyboardActions): Likewise. + (getInputMap): Likewise. + (getActionMap): Likewise. + (createActionMap): Likewise. + * javax/swing/text/AbstractDocument.java + (getStartPosition): Implement. + (getEndPosition): Likewise. + * javax/swing/text/DefaultEditorKit.java + (CopyAction): New class. + (CutAction): Likewise. + (DefaultKeyTypedAction): Likewise. + (InsertBreakAction): Likewise. + (InsertContentAction): Likewise. + (InsertTabAction): Likewise. + (PasteAction): Likewise. + (defaultActions): New static table. + (createCaret): Implement. + (getActions): Likewise. + * javax/swing/text/JTextComponent.java + (KeymapWrapper): New private class. + (KeymapActionMap): Likewise. + (DefaultKeymap): New class. + (keymaps): New static table. + (keymap): New field. + (getKeymap): Implement. + (removeKeymap): Likewise. + (addKeymap): Likewise. + (setKeymap): Likewise. + (loadKeymap): Likewise. + (getActions): Likewise. + (margin): New field. + (JTextComponent): Build and install default keymap. + * javax/swing/text/TextAction.java + (textAction): Call super properly. + (getTextComponent): Implement. + * javax/swing/text/Utilities.java + (drawTabbedText): Adjust position by ascent. + +2004-08-31 David Jee + + PR AWT/17156 + + * gnu/java/awt/peer/gtk/GtkMenuItemPeer.java + (setEnabled): Make it a native method. + * java/awt/DefaultKeyboardFocusManager.java + (postProcessKeyEvent): Only post event if the menu item + is active. + * java/awt/MenuItem.java: + Private field 'enabled' should be true by default. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c + (setEnabled): New function. + +2004-08-31 David Jee + + PR AWT/17059 + + * gnu/java/awt/peer/gtk/GtkMenuBarPeer.java + (nativeSetHelpMenu): New native method declaration. + (addHelpMenu): Call nativeSetHelpMenu(). + (addMenu): Remove. + * java/awt/MenuBar.java + (setHelpMenu): Call addNotify() on the new help menu. + (add): Call addNotify() on the new menu. + (addNotify): Set the help menu if one exists. + * java/awt/peer/MenuBarPeer.java + (addMenu): Remove. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c + (nativeSetHelpMenu): New method. + +2004-08-31 Graydon Hoare + + * Makefile.am: Add new files. + * Makefile.in: Regenerate. + * javax/swing/Box.java: Fix setting of layout in ctor. + * javax/swing/JScrollPane.java: Scroll headers as well. + * javax/swing/JTable.java: Reimplement. + * javax/swing/JViewPort.java: Only add non-null children. + * javax/swing/ScrollPaneLayout.java: Correct header calculations. + * javax/swing/Timer.java: Fix stopping null waker. + * javax/swing/plaf/basic/BasicTableHeaderUI.java: New file. + * javax/swing/plaf/basic/BasicTableUI.java: New file. + * javax/swing/table/DefaultTableCellRenderer.java: Configure. + * javax/swing/table/DefaultTableColumnModel.java: Flesh out. + * javax/swing/table/DefaultTableModel.java: Clean up. + * javax/swing/table/JTableHeader.java: Implement. + +2004-08-31 Mark Wielaard + + * javax/swing/JSpinner.java (getChangeListeners): Remove double + semi-colon. + +2004-08-31 Mark Wielaard + + * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c: + Declare variables at top of functions/block. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise. + +2004-08-31 Mark Wielaard + + * java/lang/Rectangle.java (intersects): Check r.width and r.height + first. + +2004-08-31 Michael Koch + + * javax/swing/text/PlainView.java + (selectedColor): New field. + (unselectedColor): Likewise. + (font): Likewise. + (updateMetrics): New method. + (lineToRect): Likewise. + (modelToView): Likewise. + (drawSelectedText): Use color from JTextComponent ad draw with + Utilities class. + (drawUnselectedText): Likewise. + (paint): Initialize helper fields. + * javax/swing/text/View.java + (getChildAllocation): New method. + (getViewIndex): Likewise. + (getToolTipText): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/text/Utilities.java + (drawTabbedText): Reimplemented. + (getTabbedTextWidth): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextUI.java + (installDefaults): Install caret and highlighter. + (modelToView): Use Bias.Forward when calling sibling. + * javax/swing/text/AbstractDocument.java + (ElementEdit): Implements DocumentEvent.ElementChange. + (ElementEdit.ElementEdit): New method. + (ElementEdit.getChildrenAdded): Likewise. + (ElementEdit.getChildrenRemoved): Likewise. + (ElementEdit.getElement): Likewise. + (ElementEdit.getIndex): Likewise. + * javax/swing/text/DefaultCaret.java + (color): Removed. + (textComponent): Renamed from parent, made private. + (selectionVisible): Renamed from vis_sel, made private. + (blinkRate): Renamed from blink, made private. + (magicCaretPosition): Renamed from magic, made private. + (visible): Renamed from vis, made private. + (dot): Made private. + (mark): Likewise. + (deinstall): Remove as MouseMotionListener. + (install): Initialize textComponent first. Add as MouseMotionListener. + (paint): Reimplemented. + * javax/swing/text/JTextComponent.java + (setCaret): Deinstall old caret, install new one and fire property + change after setting property. + (setHighlighter): Deinstall old highlighter, install new one and fire + property change after setting property. + (setCaretColor): Fire property change after setting property. + (setDisabledTextColor): Likewise. + (setSelectedTextColor): Likewise. + (setSelectionColor): Likewise. + (modelToView): New method. + +2004-08-31 Michael Koch + + * javax/swing/text/AbstractDocument.java + (getText): Simplified. + * javax/swing/text/Segment.java + (current): New field. + (current): Reimplemented. + (first): Likewise. + (getIndex): Likewise. + (last): Likewise. + (next): Likewise. + (previous): Likewise. + (setIndex): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicButtonUI.java + (defaultTextIconGap): Made protected. + (defaultTextShiftOffset): Likewise. + (textShiftOffset): New field. + (clearTextShiftOffset): New method. + (getTextShiftOffset): Likewise. + (setTextShiftOffset): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextUI.java + (installUI): Add eventHandler as property listener. + (uninstallUI): remove eventHandler as propert listener. + (installDefaults): Added comment. + (installListeners): Likewise. + (installKeyboardActions): Likewise. + (uninstallDefaults): Likewise. + (uninstallListeners): Likewise. + (uninstallKeyboardActions): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/text/AbstractDocument.java: + Fixed some typos in comments. + (insertString): Reimplemented. + (remove): Likewise. + (replace): New method. + (children): Dont use fully qualified class name. + (DefaultDocumentEvent.offset): Renamed from off. + (DefaultDocumentEvent.length): Renamed from len. + (DefaultDocumentEvent.type): New field. + (DefaultDocumentEvent.DefaultDocumentEvent): New constructor. + (DefaultDocumentEvent.getType): Implemented. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextUI.java + (RootView.textComponent): Removed. + (RootView.RootView): Don't initialize textComponent. + (RootView.getViewFactory): New method. + (EventHandler): New inner class. + (rootView): Initialize at instance creation. + (eventHandler): New field. + (installUI): Don't create view hierarchy directly, + call modelChanged() instead. + (modelChanged): New method. + * javax/swing/text/JTextComponent.java + (setDocument): Fire property change event. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicTextUI.java + (RootView.paint): Removed debug output. + (paintSafely): Draw highlighter before text. + (paintBackground): Use background color of text component. + * javax/swing/plaf/basic/BasicToggleButtonUI.java: + Reformatted. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicToolBarUI.java + (BasicToolBarUI): Fixed arguments for constructor. + (createUI): Fixed creation of object. + +2004-08-31 Michael Koch + + * javax/swing/DefaultListSelectionModel.java + (fireValueChanged): Renamed from fireSelectionValueChanged, + made protected. + +2004-08-31 Michael Koch + + * javax/swing/text/TabSet.java + (TabSet): Implements java.io.Serializable. + * javax/swing/text/TabStop.java + (TabStop): Implements java.io.Serializable. + (TabStop): Made public. + +2004-08-31 Michael Koch + + * javax/swing/JComponent.java + (setUI): Fire PropertyChange. + * javax/swing/JLabel.java + (text): Renamed from labelText. + (horizontalAlignment): New default vlaue. + (icon): Renamed from activeIcon. + (displayedMnemonic): Renamed from mnemonicKey, added default value. + (displayedMnemonicIndex): Renamed from underlineChar. + (setDisplayedMnemonic): Reimplemented. + * javax/swing/JRadioButton.java + (JRadioButton): New constructors. + * javax/swing/JTextField.java + (JTextField): Throw exception if colums < 0, initialitialz + this.columns directly and initialize document with text conditionally. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicFormattedTextFieldUI.java, + javax/swing/plaf/basic/BasicPasswordFieldUI.java, + javax/swing/plaf/basic/BasicTextAreaUI.java: New files. + * javax/swing/text/FieldView.java + (paint): Just call super method for now. + * Makefile.am: Added new files. + * Makefile.in: Regenerated. + +2004-08-31 Ka-Hing Cheung + + * javax/swing/AbstractSpinnerModel.java, + javax/swing/JSpinner.java, + javax/swing/SpinnerNumberModel.java, + javax/swing/plaf/basic/BasicSpinnerUI.java: + New files. + * javax/swing/plaf/basic/BasicLookAndFeel.java + (initClassDefaults): Added defaults for BasicSpinnerUI. + +2004-08-31 Michael Koch + + * Makefile.am: Added new files. + * Makefile.in: Regenerated. + +2004-08-31 Michael Koch + + * javax/swing/TransferHandler.java, + javax/swing/plaf/basic/ComboPopup.java: New files + * Makefile.am: Added javax/swing/TransferHandler.java and + javax/swing/plaf/basic/ComboPopup.java + * Makefile.in: Regenerated. + +2004-08-31 Roman Kennke + + * javax/swing/text/Utilities.java: New file. + +2004-08-31 Michael Koch + + * Makefile.am: Added javax/swing/text/Utilities.java. + * Makefile.in: Regenerated. + +2004-08-31 Graydon Hoare + + * javax/swing/text/SimpleAttributeSet.java: New file. + * javax/swing/text/StyleConstants.java: New file. + * javax/swing/text/StyleContext.java: New file. + * javax/swing/text/TabSet.java: New file. + * javax/swing/text/TabStop.java: New file. + * javax/swing/text/AbstactDocument.java: + (AbstractElement): Implement attribute support. + * javax/swing/text/AttributeSet.java + (NameAttribute): New static field. + (ResolveAttribute): New static field. + * Makefile.am: Update for new files. + * Makefile.in: Regenerate. + +2004-08-31 Craig Black + + * gnu/java/awt/peer/gtk/GdkGraphics.java + (drawImage): Add support for scaling pixmaps. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c + (copyAndScalePixmap): New native method. + +2004-08-31 Thomas Fitzsimmons + + PR AWT/16121 + * jni/gtk-peer/gthread-jni.c: Include stdio.h. Eliminate + type-punning compiler warnings using unions. + (throw): Replace bzero with memset. + +2004-08-31 Andreas Tobler + Thomas Fitzsimmons + + * jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: Move + NSA_PB macros to gtkpeer.h. Include gtkpeer.h. + * jni/gtk-peer/gtkpeer.h: Move NSA_PB macros here. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c + (nativeSetIconImageFromDecoder): Use NSA_GET_PB_PTR macro. + +2004-08-31 Mark Wielaard + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: + #include gdk.h, not gtk.h. #include jni.h, native_state.h, string.h + and stdlib.h, not gtkpeer.h. + (*vm): New static variable. + (areaPreparedID): Make static. + (areaUpdatedID): Likewise. + (area_prepared): Get and use JNIEnv through stored JavaVM *vm. + (area_prepared): Likewise. + (area_updated): Likewise. + (closed): Likewise. + (initStaticState): Initialize *vm javaVM. + (pumpBytes): Use given env, not global gdk_env. + +2004-08-31 Mark Wielaard + + * java/awt/geom/CubicCurve2D.java (solveCubic): Removed duplicate + comments. + +2004-08-31 Sven de Marothy + + * java/awt/geom/CubicCurve2D.java: Reindent. + (contains): Implemented. + (intersects): Implemented. + * java/awt/geom/QuadCurve2D.java: Likewise. + * java/awt/geom/GeneralPath.java: Reindent and document. + Fully (re)implemented using separate xpoints and ypoints + float[] coords. + * java/awt/geom/RoundRectangle2D.java: Several bugfixes (Bug #6007). + +2004-08-31 Michael Koch + + * javax/swing/JMenuItem.java + (getMenuDragMouseListeners): New method. + (getMenuKeyListeners): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/AbstractButton.java + (model): Made protected. + (actionListener): Likewise. + (changeListener): Likewise. + (itemListener): Likewise. + (multiClickThreshhold): New field. + (getActionListeners): New method. + (getChangeListeners): Likewise. + (getItemListeners): Likewise. + (fireItemStateChanged): Simplified implementation. + (fireActionPerformed): Likewise. + (fireStateChanged): Likewise. + (getMultiClickThreshhold): New method. + (setMultiClickThreshhold): Likewise. + +2004-08-31 Tom Tromey + + * java/awt/image/Kernel.java (clone): Use super.clone(). + +2004-08-31 David Jee + + PR AWT/16682 + * gnu/java/awt/peer/gtk/GtkFramePeer.java + (nativeSetIconImage): Rename to nativeSetIconImageFromDecoder. + (nativeSetIconImageFromData): New native method declaration. + (setIconImage): Handle images not produced from GdkPixbufDecoder. + * gnu/java/awt/peer/gtk/GtkImage.java + (getPixelCache): New method. + (getColorModel): New method. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c + (nativeSetIconImage): Rename to nativeSetIconImageFromDecoder. + (free_pixbuf_data): New helper function. + (nativeSetIconImageFromData): New function. + +2004-08-31 Graydon Hoare + + PR SWING/16576 + * javax/swing/JLayeredPane.java + (setLayer): Permit changing layer after addition. + (setPosition): Permit over-length positions. + (layerToRange): Compare intValue()s. + * javax/swing/Box.java (createHorizontalBox): Implement. + (createRigidArea): Likewise. + (createVerticalBox): Likewise. + +2004-08-31 Kim Ho + + * java/awt/Component.java: + (processMouseEvent): Consume event after + listeners process it. + (processMouseMotionEvent): ditto. + (processMouseWheelEvent): ditto. + * java/awt/Container.java: + (acquireComponentForMouseEvent): + Do not dispatch to events that have been + removed from the Container. + (handleEvent): Consume the MouseEvents. + * javax/swing/RepaintManager.java: + (paintDirtyRegions): Do not add to list of + damaged areas if the component has no root. + +2004-08-31 Michael Koch + + * javax/swing/plaf/basic/BasicMenuItemUI.java: Clean ip imports. + +2004-08-31 Mark Wielaard + + * gnu/java/awt/peer/gtk/GtkToolkit.java (getFontPeer): Don't return + null when a MissingResourceException is thrown. Should never happen. + +2004-08-31 Mark Wielaard + + * java/awt/EventQueue.java (postEvent): Throw NullPointerException + when argument is null. + +2004-08-31 Mark Wielaard + + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c + (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilter): + Define hid at start of function. + (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter): + Likewise. + +2004-08-31 Mark Wielaard + + * gnu/java/awt/EmbeddedWindow.java: Reindent. + * javax/swing/JButton.java: Reindent. + * javax/swing/JCheckBox.java: Reindent. + +2004-08-31 Mark Wielaard + + * Makefile.am (gtk_c_source_files): Added + jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c. + (gtk_awt_peer_sources): Added + gnu/java/awt/peer/gtk/GThreadMutex.java and + gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java. + * Makefile.in: Regenerated. + +2004-08-31 Archie Cobbs + + * jni/gtk-peer/gthread-jni.c: don't #include nonexistent files + +2004-08-31 Steven Augart + + * jni/gtk-peer/gthread-jni.c (c-font-lock-extra-types): + Added jfieldID, jmethodID. + +2004-08-31 Mark Wielaard + + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c + (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): Initialize + gdk_env before calling any gdk or gtk function. + + * gnu/java/awt/peer/gtk/GtkMainThread.java (gtkInitCalled): New field. + (GtkMainThread): Call wait() in while loop waiting for gtkInitCalled. + (run): Set gtkInitCalled. + +2004-08-31 Steven Augart + + * gnu/java/awt/peer/gtk/GtkMainThread.java (run): Pass the value of + the gnu.classpath.awt.gtk.portable.native.sync system property to C. + + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c + (Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): New argument, + portableNativeSync. Delegate PORTABLE_NATIVE_SYNC work to + init_glib_threads. + (init_glib_threads): New function. + +2004-08-31 Mark Wielaard + + * jni/gtk-peer/gthread-jni.c: Define MIN_, MAX_ and NORM_ + PRIORITY when not already defined in header file. + +2004-08-31 Mark Wielaard + + * jni/gtk-peer/gthread-jni.c (setup_cache): Call + ExceptionOccurred, not ExceptionCheck, when we don't have JNI 1.2. + +2004-08-31 Steven Augart + + * gnu/native/jni/gtk-peer/gthread-jni.c: Indentation fixes. + Implemented missing functions for GTK2. + Added error handling. + Renamed static functions out of the g_ namespace. + Added TRACE_API_CALLS, EXPLAIN_TROUBLE, EXPLAIN_BROKEN, + EXPLAIN_BADLY_BROKEN, and DELETE_LOCAL_REFS options. + Rewrote global-reference code. + Eliminated cascading errors. + (mutex_trylock_jni_impl) Fully implemented. + (cond_timed_wait_jni_impl) Went from millisecond to microsecond + resolution. + (setup_cache) New function. + (mutex_cond_wait_jni_impl, mutex_cond_timed_wait_jni_impl) Fixed + bug where they were not unlocking the GMutex associated with the + condition variable during the wait on that condition variable. + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c, + native/jni/gtk-peer/gthread-jni.c, + native/jni/gtk-peer/gthread-jni.h + (g_thread_jni_functions): Renamed to ... + (portable_native_sync_jni_functions): this name. + (gdk_vm): Renamed to... + (the_vm): this name. + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c + (gdk_vm): Removed duplicate definition. + (gtkInit): Removed stray message to stdout. + (gtkInit): Use g_malloc and g_free instead of malloc and free. + (gtkInit): Fix a const assignment bug. + (gtkInit): Simplified code. + + * gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java, + native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c, + native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h, + gnu/java/awt/peer/gtk/GThreadMutex.java: + New files. + +2004-08-31 Mark Wielaard + + * javax/swing/Box.java: Put FIXME comment above class declaration. + * javax/swing/JButton.java: Remove illegal L&F HTML from comments. + * javax/swing/JCheckBox.java: Likewise. + * javax/swing/JDialog.java: Likewise. + * javax/swing/JRadioButton.java: Likewise. + * javax/swing/JToggleButton.java: Likewise. + * javax/swing/UIManager.java: Likewise. + * javax/swing/border/TitledBorder.java: Likewise. + * javax/swing/plaf/basic/BasicLabelUI.java: Likewise. + * javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise. + * javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java: Likewise. + * javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise. + * javax/swing/plaf/basic/BasicScrollBarUI.java: Likewise. + * javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise. + * javax/swing/text/JTextComponent.java: Likewise. + +2004-08-31 David Jee + + PR AWT/16682 + * gnu/java/awt/peer/gtk/GtkFramePeer.java + (setIconImage): Add a FIXME for unhandled cases. + +2004-08-31 Thomas Fitzsimmons + + PR AWT/16040 + * gnu/awt/LightweightRedirector.java: Call getModifiersEx, not + getModifiers. Replace old button masks with new ones. + * gnu/awt/xlib/XEventLoop.java: Likewise. + * gnu/java/awt/peer/gtk/GtkButtonPeer.java: Likewise. + * gnu/java/awt/peer/gtk/GtkComponentPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise. + * gnu/java/awt/peer/gtk/GtkListPeer.java: Likewise. + * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Likewise. + * java/awt/AWTKeyStroke.java: Remove old modifier masks. + * java/awt/Component.java: Replace old modifier masks with new + ones. + * java/awt/Container.java: Call getModifiersEx, not + getModifiers. + * java/awt/DefaultKeyboardFocusManager.java: Likewise. Remove + old modifier masks. + * javax/swing/JMenuItem.java: Replace old button masks with new + ones. + * javax/swing/KeyStroke.java: Call getModifiersEx, not + getModifiers. + * javax/swing/SwingUtilities.java: Likewise. + * javax/swing/plaf/basic/BasicButtonListener.java: Likewise. + * javax/swing/plaf/basic/BasicInternalFrameUI.java: Likewise. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Replace old + mask macros with new ones. + * jni/gtk-peer/gtkpeer.h: Replace old button and modifier mask + macros with new ones representing new masks. + +2004-08-31 Craig Black + + * gnu/java/awt/peer/gtk/GdkGraphics.java + (drawRoundRect): Implemented. + (fillRoundRect): Implemented. + * gnu/java/awt/peer/gtk/GdkGraphics2D.java + (drawRoundRect): Reimplemented to match GdkGraphics. + (fillRoundRect): Reimplemented to match GdkGraphics. + +2004-08-31 Mark Wielaard + + * Makefile.in: Regenerated. + +2004-08-31 Michael Koch + + * gnu/java/awt/EmbeddedWindow.java + (addNotify): Use AccessController to allow execution of privileged + code. + +2004-08-31 Michael Koch + + * gnu/java/awt/EmbeddedWindow.java + (static): Removed. + (addNotify): Set peer via reflection. + (setWindowPeer): Removed. + * gnu/java/awt/natEmbeddedWindow.cc: Removed. + * Makefile.am (nat_source_files): + Removed gnu/java/awt/natEmbeddedWindow.cc. + +2004-08-31 Bryce McKinlay + + * Makefile.am: Add gnu/java/security/action/GetPropertyAction.java + and gnu/java/security/action/SetAccessibleAction.java. + +2004-08-31 Bryce McKinlay + + * gnu/java/security/action/GetPropertyAction.java (setParameters): + Renamed from 'setName'. New 2-argument form with default value. + (run): Pass default 'value' parameter to System.getProperty(). + * gnu/java/security/action/SetAccessibleAction.java: Fix javadoc + typos. + +2004-08-31 Bryce McKinlay + + * gnu/java/security/action/GetPropertyAction.java: New class. + * gnu/java/security/action/SetAccessibleAction.java: New class. + +2004-08-31 David Jee + + * gnu/java/awt/peer/gtk/GtkFramePeer.java + (setIconImage): Check if image is null. + +2004-08-31 David Jee + + * gnu/java/awt/peer/gtk/GtkFramePeer.java + (create): Set the icon image. + (nativeSetIconImage): New native method declaration. + (setIconImage): Implement. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c + (nativeSetIconImage): New function. + +2004-08-31 Dalibor Topic + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c + (filenameFilterCallback): Declare local variable accepted before use. + +2004-08-31 Dalibor Topic + + * gnu/java/awt/ComponentDataBlitOp.java: + Cleaned up imports. + +2004-08-31 Tom Tromey + + * gnu/java/awt/peer/GLightweightPeer.java, + gnu/java/awt/peer/gtk/GdkGraphics2D.java, + gnu/java/awt/peer/gtk/GtkComponentPeer.java, + javax/swing/JScrollPane.java: Removed + redundant imports. + +2004-08-31 David Jee + + * java/awt/DefaultKeyboardFocusManager.java + (postProcessKeyEvent): Only activate MenuShortcuts on KEY_PRESSED + event. Fix shift modifier checking. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c + (accel_attach): Remove. + (setupAccelGroup): Remove calls to accel_attach. + +2004-08-31 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GtkArg.java: Remove file. + * gnu/java/awt/peer/gtk/GtkArgList.java: Remove file. + + * Makefile.am (gtk_awt_peer_sources): Remove GtkArg.java and + GtkArgList.java. + (gtk_c_files): Use CAIRO_CFLAGS and PANGOFT2_CFLAGS, not _LIBS. + * Makefile.in: Regenerate. + * gnu/java/awt/peer/gtk/GtkButtonPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c + (create(String)): New method. + (create): Call new create method. + (getArgs): Remove method. + * gnu/java/awt/peer/gtk/GtkCheckboxPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c + (nativeCreate): Rename to create. + (gtkSetLabel): Rename to gtkButtonSetLabel. + (gtkToggleButtonSetActive): New method. + (create): Call gtkToggleButtonSetActive and gtkButtonSetLabel. + (setState): Replace set call with gtkToggleButtonSetActive. + (setLabel): Replace gtkSetLabel call with gtkButtonSetLabel. + (getArgs): Remove method. + * gnu/java/awt/peer/gtk/GtkComponentPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c + (gtkWidgetSetSensitive): New method. + (gtkWidgetSetParent): Likewise. + (GtkComponentPeer): Call setParent, setComponentBounds and + setVisibleAndEnabled. + (setParent): New method. + (setComponentBounds): New method. + (setVisibleAndEnabled): New method. + (setEnabled): Call gtkWidgetSetSensitive. + (getArgs): Remove method. + Remove all set methods. + * gnu/java/awt/peer/gtk/GtkDialogPeer.java (create): Call + gtkWindowSetModal, setTitle and setResizable. + (getArgs): Remove method. + * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java + (setComponentBounds): New method. + * gnu/java/awt/peer/gtk/GtkFramePeer.java (setResizable): + Replace set call with gtkWindowSetResizable. + (getArgs): Remove method. + (create): Call setTitle and setResizable. + * gnu/java/awt/peer/gtk/GtkWindowPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c + (gtkWindowSetTitle): New method. + (gtkWindowSetResizable): New method. + (gtkWindowSetModal): New method. + (setParent): New method. + (setVisibleAndEnabled): New method. + (getArgs): Remove method. + (setTitle): Call gtkWindowSetTitle. + (setResizable): Call gtkWindowSetResizable. + * jni/gtk-peer/gtkpeer.h [DEBUG_LOCKING]: New define to turn on + and off locking instrumentation. + +2004-08-31 Kim Ho + + * Makefile.am: Add new file. + * Makefile.in: Regenerate. + * gcj/Makefile.in: Regenerate + * include/Makefile.in: + * java/awt/Container.java: + (acquireComponentForMouseEvent): Respect + the event mask when looking for candidate. + * javax/swing/JComponent.java: + Remove toolTip field. + (createToolTip): Create a tooltip on demand. + (setToolTipText): Register with the ToolTipManager. + (getToolTipText(MouseEvent)): Return getToolTipText(). + * javax/swing/JToolTip.java: Implement. + * javax/swing/Timer.java: Jalopy. + (restart): Call stop, then start. + (stop): Interrupt the timer rather than wait for + the timer to come to a stop naturally. + * javax/swing/ToolTipManager.java: Implement. + * javax/swing/plaf/basic/BasicLookAndFeel.java: + Change ToolTip.background color. + * javax/swing/plaf/basic/BasicToolTipUI.java: + Implement. + * testsuite/Makefile.in: Regenerate + +2004-08-31 Jerry Quinn + + * java/awt/image/DirectColorModel.java (DirectColorModel): Fix + constructor param comments. + +2004-08-31 Thomas Fitzsimmons + + * java/awt/Component.java: Document AWT 1.0 event handler + methods. + +2004-08-31 Roman Kennke + + * javax/swing/Box.java: + (createGlue): Implemented + (createHorizontalGlue): Implemented + (createHorizontalStrut): Implemented + (createVerticalGlue): Implemented + (createVerticalStrut): Implemented + +2004-08-31 David Jee + + * gnu/java/awt/peer/gtk/GtkChoicePeer.java + (GtkChoicePeer): Do not automatically select first item. + (getHistory): Remove. + (nativeGetSelected): New method. + (nativeRemoveAll): New method. + (add): Use nativeGetSelected() instead of getHistory(). + (remove): Likewise. + (removeAll): Call nativeRemoveAll(). + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c + (create): Migrate to GtkComboBox. + (append): Likewise. + (nativeAdd): Likewise. + (nativeRemove): Likewise. + (select): Likewise. + (nativeRemoveAll): New method. + (nativeGetSelected): New method. + (selection_changed): New method. + (getHistory): Remove. + (item_activate): Remove. + (item_removed): Remove. + (connect_choice_item_selectable_hook): Remove. + +2004-08-31 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (create): Use tf + variable in setEditable call. + + * gnu/java/awt/peer/gtk/GtkTextFieldPeer.java, + jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c + (gtkWidgetSetBackground): New method. + (gtkWidgetSetForeground): Likewise. + (create): Set peer's editable state based on awtComponent's. + + * java/awt/Button.java (Button()): Use empty string rather than + null in no-label constructor. + +2004-08-31 Roman Kennke + + * javax/swing/BoxLayout.java: Reimplement. + +2004-08-31 Thomas Fitzsimmons + + * gnu/java/awt/peer/gtk/GdkGraphics.java, + gnu_java_awt_peer_gtk_GdkGraphics.c + (initState(GtkComponentPeer)): Don't return array of colour + values. + (GdkGraphics(int,int)): Set default font to size 12. + (GdkGraphics(GtkComponentPeer)): Set graphics colour to + component's foreground colour. + * gnu/java/awt/peer/gtk/GdkGraphics2D.java, + gnu_java_awt_peer_gtk_GdkGraphics2D.c + (initState(GtkComponentPeer)): Don't return array of colour + values. + (GdkGraphics2D(GtkComponentPeer)): Set foreground and background + colours to component's colours. + (current_colors_of_widget): Remove function. + * gnu/java/awt/peer/gtk/GtkOffScreenImage.java (getGraphics): + Return a new graphics object. + * java/awt/Font.java (toString): Fix format. + * java/awt/Graphics.java (toString): Likewise. + +2004-08-31 Craig Black + + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c + (addTearOff): New function. + * gnu/java/awt/peer/gtk/GtkMenuPeer.java (addTearOff): + New native method. + (init): Call addTearOff() when menu.isTearOff(). + +2004-08-31 Bryce McKinlay + + * gnu/java/awt/ClasspathToolkit.java (createImageProducer): New. + Default implementation. + * gnu/java/awt/peer/gtk/GtkToolkit.java (createImageProducer): New. + Implement using GdkPixbufDecoder. + +2004-08-31 David Jee + + * gnu/java/awt/peer/gtk/GtkComponentPeer.java + (GtkComponentPeer): Use gtkWidgetGetPreferredDimensions() for + setting the size of GtkFileDialogPeers. + * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c + (gtkWidgetGetPreferredDimensions): For widgets extending GtkWindow, + use their default sizes rather than their natural requisitions. + +2004-08-31 Michael Koch + + * javax/swing/JFormattedTextField.java + (JFormattedTextField): Implemented. + * javax/swing/text/DefaultEditorKit.java + (BeepAction): New inner class. + * javax/swing/text/Segment.java + (partialReturn): New field. + (setPartialReturn): New method. + (isPartialReturn): Likewise. + * javax/swing/text/View.java + (createFragment): Fixed typo. + (getStartOffset): New method. + (getEndOffset): Likewise. + +2004-08-31 Michael Koch + + * javax/swing/table/DefaultTableColumnModel.java + (serialVersionUID): Made private. + (listenerList): Initialize. + (changeEvent): Initialize. + * javax/swing/table/JTableHeader.java + (JTableHeader): New constructors. + (createDefaultColumnModel): New method. + * javax/swing/table/TableColumn.java + (setHeaderRenderer): Simplified code. + (setCellRenderer): Likewise. + (setWidth): Likewise. + 2004-08-31 Tom Tromey * java/text/AttributedString.java (AttributedString): Use diff --git a/libjava/Makefile.am b/libjava/Makefile.am index 3c2fe848e45..cc80edbed5e 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -268,6 +268,7 @@ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c \ +jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \ jni/gtk-peer/gthread-jni.c \ jni/classpath/jcl.c \ jni/classpath/jnilink.c \ @@ -284,8 +285,6 @@ gnu/java/awt/peer/gtk/GdkGraphics.java \ gnu/java/awt/peer/gtk/GdkGraphics2D.java \ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \ gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \ -gnu/java/awt/peer/gtk/GtkArg.java \ -gnu/java/awt/peer/gtk/GtkArgList.java \ gnu/java/awt/peer/gtk/GtkButtonPeer.java \ gnu/java/awt/peer/gtk/GtkCanvasPeer.java \ gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \ @@ -319,7 +318,10 @@ gnu/java/awt/peer/gtk/GtkTextAreaPeer.java \ gnu/java/awt/peer/gtk/GtkTextComponentPeer.java \ gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \ gnu/java/awt/peer/gtk/GtkToolkit.java \ -gnu/java/awt/peer/gtk/GtkWindowPeer.java +gnu/java/awt/peer/gtk/GtkWindowPeer.java \ +gnu/java/awt/peer/gtk/GThreadMutex.java \ +gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java + gtk_jni_headers = $(patsubst %.java,jniinclude/%.h,$(subst /,_,$(gtk_awt_peer_sources))) @@ -344,7 +346,8 @@ jni/classpath/primlib.h lib_gnu_java_awt_peer_gtk_la_CFLAGS = \ -Ijniinclude -I$(srcdir)/jni/classpath \ - -I$(srcdir)/jni/gtk-peer $(GTK_CFLAGS) $(LIBART_CFLAGS) + -I$(srcdir)/jni/gtk-peer $(PEDANTIC_CFLAGS) $(GTK_CFLAGS) $(LIBART_CFLAGS) \ + $(CAIRO_CFLAGS) $(PANGOFT2_CFLAGS) lib_gnu_java_awt_peer_gtk_la_GCJFLAGS = $(AM_GCJFLAGS) -fjni lib_gnu_java_awt_peer_gtk_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBART_LIBS) $(CAIRO_LIBS) $(PANGOFT2_LIBS) lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES = $(gtk_jni_headers) libgcj-@gcc_version@.jar libgcj.la libgcj.spec @@ -1327,12 +1330,19 @@ javax/swing/border/TitledBorder.java \ javax/swing/GrayFilter.java \ javax/swing/AbstractAction.java \ javax/swing/AbstractButton.java \ +javax/swing/AbstractSpinnerModel.java \ javax/swing/plaf/basic/BasicArrowButton.java \ javax/swing/plaf/basic/BasicButtonListener.java \ javax/swing/plaf/basic/BasicButtonUI.java \ javax/swing/plaf/basic/BasicCheckBoxUI.java \ +javax/swing/plaf/basic/BasicColorChooserUI.java \ +javax/swing/plaf/basic/BasicComboBoxUI.java \ +javax/swing/plaf/basic/BasicComboBoxEditor.java \ +javax/swing/plaf/basic/BasicComboBoxRenderer.java \ +javax/swing/plaf/basic/BasicComboPopup.java \ javax/swing/plaf/basic/BasicDesktopIconUI.java \ javax/swing/plaf/basic/BasicDesktopPaneUI.java \ +javax/swing/plaf/basic/BasicFormattedTextFieldUI.java \ javax/swing/plaf/basic/BasicGraphicsUtils.java \ javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \ javax/swing/plaf/basic/BasicInternalFrameUI.java \ @@ -1343,6 +1353,7 @@ javax/swing/plaf/basic/BasicMenuBarUI.java \ javax/swing/plaf/basic/BasicMenuItemUI.java \ javax/swing/plaf/basic/BasicOptionPaneUI.java \ javax/swing/plaf/basic/BasicPanelUI.java \ +javax/swing/plaf/basic/BasicPasswordFieldUI.java \ javax/swing/plaf/basic/BasicPopupMenuUI.java \ javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \ javax/swing/plaf/basic/BasicProgressBarUI.java \ @@ -1354,19 +1365,25 @@ javax/swing/plaf/basic/BasicScrollBarUI.java \ javax/swing/plaf/basic/BasicScrollPaneUI.java \ javax/swing/plaf/basic/BasicSeparatorUI.java \ javax/swing/plaf/basic/BasicSliderUI.java \ +javax/swing/plaf/basic/BasicSpinnerUI.java \ javax/swing/plaf/basic/BasicSplitPaneDivider.java \ javax/swing/plaf/basic/BasicSplitPaneUI.java \ javax/swing/plaf/basic/BasicTabbedPaneUI.java \ +javax/swing/plaf/basic/BasicTableUI.java \ +javax/swing/plaf/basic/BasicTableHeaderUI.java \ +javax/swing/plaf/basic/BasicTextAreaUI.java \ javax/swing/plaf/basic/BasicTextFieldUI.java \ javax/swing/plaf/basic/BasicTextUI.java \ javax/swing/plaf/basic/BasicToggleButtonUI.java \ javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \ javax/swing/plaf/basic/BasicToolBarUI.java \ +javax/swing/plaf/basic/BasicToolTipUI.java \ javax/swing/plaf/basic/BasicTreeUI.java \ javax/swing/plaf/basic/BasicViewportUI.java \ javax/swing/plaf/basic/BasicLookAndFeel.java \ javax/swing/plaf/basic/BasicBorders.java \ javax/swing/plaf/basic/BasicIconFactory.java \ +javax/swing/plaf/basic/ComboPopup.java \ javax/swing/plaf/BorderUIResource.java \ javax/swing/plaf/UIResource.java \ javax/swing/plaf/ButtonUI.java \ @@ -1415,6 +1432,10 @@ javax/swing/colorchooser/AbstractColorChooserPanel.java \ javax/swing/colorchooser/ColorChooserComponentFactory.java \ javax/swing/colorchooser/ColorSelectionModel.java \ javax/swing/colorchooser/DefaultColorSelectionModel.java \ +javax/swing/colorchooser/DefaultPreviewPanel.java \ +javax/swing/colorchooser/DefaultSwatchChooserPanel.java \ +javax/swing/colorchooser/DefaultHSBChooserPanel.java \ +javax/swing/colorchooser/DefaultRGBChooserPanel.java \ javax/swing/filechooser/FileFilter.java \ javax/swing/filechooser/FileSystemView.java \ javax/swing/filechooser/FileView.java \ @@ -1460,6 +1481,7 @@ javax/swing/JRadioButton.java \ javax/swing/JRootPane.java \ javax/swing/JScrollBar.java \ javax/swing/JScrollPane.java \ +javax/swing/JSpinner.java \ javax/swing/JTabbedPane.java \ javax/swing/JTextArea.java \ javax/swing/JTextField.java \ @@ -1474,11 +1496,15 @@ javax/swing/ListModel.java \ javax/swing/ListSelectionModel.java \ javax/swing/LookAndFeel.java \ javax/swing/Scrollable.java \ +javax/swing/SpinnerModel.java \ +javax/swing/SpinnerNumberModel.java \ javax/swing/Spring.java \ javax/swing/SpringLayout.java \ javax/swing/SwingConstants.java \ javax/swing/SwingUtilities.java \ javax/swing/Timer.java \ +javax/swing/ToolTipManager.java \ +javax/swing/TransferHandler.java \ javax/swing/UIDefaults.java \ javax/swing/UIManager.java \ javax/swing/UnsupportedLookAndFeelException.java \ @@ -1550,12 +1576,18 @@ javax/swing/text/PlainDocument.java \ javax/swing/text/PlainView.java \ javax/swing/text/Position.java \ javax/swing/text/Segment.java \ +javax/swing/text/SimpleAttributeSet.java \ javax/swing/text/Style.java \ +javax/swing/text/StyleConstants.java \ +javax/swing/text/StyleContext.java \ javax/swing/text/StyledDocument.java \ javax/swing/text/StyledEditorKit.java \ -javax/swing/text/TabExpander.java \ javax/swing/text/TabableView.java \ +javax/swing/text/TabExpander.java \ +javax/swing/text/TabSet.java \ +javax/swing/text/TabStop.java \ javax/swing/text/TextAction.java \ +javax/swing/text/Utilities.java \ javax/swing/text/View.java \ javax/swing/text/ViewFactory.java \ javax/swing/text/html/HTML.java \ @@ -1638,7 +1670,6 @@ javax/swing/ProgressMonitor.java \ javax/swing/ProgressMonitorInputStream.java \ javax/swing/RepaintManager.java \ javax/swing/ScrollPaneLayout.java \ -javax/swing/ToolTipManager.java \ javax/swing/ViewportLayout.java rmi_java_source_files = \ diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 9e4138d34fe..6b8e28a0bb1 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -130,8 +130,6 @@ am__lib_gnu_java_awt_peer_gtk_la_SOURCES_DIST = \ gnu/java/awt/peer/gtk/GdkGraphics2D.java \ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \ gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \ - gnu/java/awt/peer/gtk/GtkArg.java \ - gnu/java/awt/peer/gtk/GtkArgList.java \ gnu/java/awt/peer/gtk/GtkButtonPeer.java \ gnu/java/awt/peer/gtk/GtkCanvasPeer.java \ gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \ @@ -166,6 +164,8 @@ am__lib_gnu_java_awt_peer_gtk_la_SOURCES_DIST = \ gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \ gnu/java/awt/peer/gtk/GtkToolkit.java \ gnu/java/awt/peer/gtk/GtkWindowPeer.java \ + gnu/java/awt/peer/gtk/GThreadMutex.java \ + gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java \ jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c \ @@ -202,6 +202,7 @@ am__lib_gnu_java_awt_peer_gtk_la_SOURCES_DIST = \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c \ + jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \ jni/gtk-peer/gthread-jni.c jni/classpath/jcl.c \ jni/classpath/jnilink.c jni/classpath/native_state.c \ jni/classpath/primlib.c jni/gtk-peer/gthread-jni.h \ @@ -216,8 +217,6 @@ am__objects_3 = gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkClasspathF gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkGraphics2D.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkGraphicsEnvironment.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.lo \ - gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo \ - gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkCanvasPeer.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkCheckboxGroupPeer.lo \ @@ -251,7 +250,9 @@ am__objects_3 = gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkClasspathF gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkTextComponentPeer.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkTextFieldPeer.lo \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkToolkit.lo \ - gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkWindowPeer.lo + gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkWindowPeer.lo \ + gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo \ + gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo @GTK_CAIRO_TRUE@am__objects_4 = jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeer.lo \ @GTK_CAIRO_TRUE@ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.lo \ @GTK_CAIRO_TRUE@ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkGlyphVector.lo \ @@ -289,6 +290,7 @@ am__objects_5 = $(am__objects_4) \ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkToolkit.lo \ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkWindowPeer.lo \ + jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo \ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gthread-jni.lo \ jni/classpath/lib_gnu_java_awt_peer_gtk_la-jcl.lo \ jni/classpath/lib_gnu_java_awt_peer_gtk_la-jnilink.lo \ @@ -1542,12 +1544,19 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/border/TitledBorder.java \ javax/swing/GrayFilter.java javax/swing/AbstractAction.java \ javax/swing/AbstractButton.java \ + javax/swing/AbstractSpinnerModel.java \ javax/swing/plaf/basic/BasicArrowButton.java \ javax/swing/plaf/basic/BasicButtonListener.java \ javax/swing/plaf/basic/BasicButtonUI.java \ javax/swing/plaf/basic/BasicCheckBoxUI.java \ + javax/swing/plaf/basic/BasicColorChooserUI.java \ + javax/swing/plaf/basic/BasicComboBoxUI.java \ + javax/swing/plaf/basic/BasicComboBoxEditor.java \ + javax/swing/plaf/basic/BasicComboBoxRenderer.java \ + javax/swing/plaf/basic/BasicComboPopup.java \ javax/swing/plaf/basic/BasicDesktopIconUI.java \ javax/swing/plaf/basic/BasicDesktopPaneUI.java \ + javax/swing/plaf/basic/BasicFormattedTextFieldUI.java \ javax/swing/plaf/basic/BasicGraphicsUtils.java \ javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \ javax/swing/plaf/basic/BasicInternalFrameUI.java \ @@ -1558,6 +1567,7 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/plaf/basic/BasicMenuItemUI.java \ javax/swing/plaf/basic/BasicOptionPaneUI.java \ javax/swing/plaf/basic/BasicPanelUI.java \ + javax/swing/plaf/basic/BasicPasswordFieldUI.java \ javax/swing/plaf/basic/BasicPopupMenuUI.java \ javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \ javax/swing/plaf/basic/BasicProgressBarUI.java \ @@ -1569,19 +1579,25 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/plaf/basic/BasicScrollPaneUI.java \ javax/swing/plaf/basic/BasicSeparatorUI.java \ javax/swing/plaf/basic/BasicSliderUI.java \ + javax/swing/plaf/basic/BasicSpinnerUI.java \ javax/swing/plaf/basic/BasicSplitPaneDivider.java \ javax/swing/plaf/basic/BasicSplitPaneUI.java \ javax/swing/plaf/basic/BasicTabbedPaneUI.java \ + javax/swing/plaf/basic/BasicTableUI.java \ + javax/swing/plaf/basic/BasicTableHeaderUI.java \ + javax/swing/plaf/basic/BasicTextAreaUI.java \ javax/swing/plaf/basic/BasicTextFieldUI.java \ javax/swing/plaf/basic/BasicTextUI.java \ javax/swing/plaf/basic/BasicToggleButtonUI.java \ javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \ javax/swing/plaf/basic/BasicToolBarUI.java \ + javax/swing/plaf/basic/BasicToolTipUI.java \ javax/swing/plaf/basic/BasicTreeUI.java \ javax/swing/plaf/basic/BasicViewportUI.java \ javax/swing/plaf/basic/BasicLookAndFeel.java \ javax/swing/plaf/basic/BasicBorders.java \ javax/swing/plaf/basic/BasicIconFactory.java \ + javax/swing/plaf/basic/ComboPopup.java \ javax/swing/plaf/BorderUIResource.java \ javax/swing/plaf/UIResource.java \ javax/swing/plaf/ButtonUI.java \ @@ -1626,6 +1642,10 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/colorchooser/ColorChooserComponentFactory.java \ javax/swing/colorchooser/ColorSelectionModel.java \ javax/swing/colorchooser/DefaultColorSelectionModel.java \ + javax/swing/colorchooser/DefaultPreviewPanel.java \ + javax/swing/colorchooser/DefaultSwatchChooserPanel.java \ + javax/swing/colorchooser/DefaultHSBChooserPanel.java \ + javax/swing/colorchooser/DefaultRGBChooserPanel.java \ javax/swing/filechooser/FileFilter.java \ javax/swing/filechooser/FileSystemView.java \ javax/swing/filechooser/FileView.java \ @@ -1658,17 +1678,21 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/JOptionPane.java javax/swing/JPanel.java \ javax/swing/JRadioButton.java javax/swing/JRootPane.java \ javax/swing/JScrollBar.java javax/swing/JScrollPane.java \ - javax/swing/JTabbedPane.java javax/swing/JTextArea.java \ - javax/swing/JTextField.java javax/swing/JToggleButton.java \ - javax/swing/JToolTip.java javax/swing/JTree.java \ - javax/swing/JViewport.java javax/swing/JWindow.java \ - javax/swing/KeyStroke.java javax/swing/ListCellRenderer.java \ - javax/swing/ListModel.java javax/swing/ListSelectionModel.java \ + javax/swing/JSpinner.java javax/swing/JTabbedPane.java \ + javax/swing/JTextArea.java javax/swing/JTextField.java \ + javax/swing/JToggleButton.java javax/swing/JToolTip.java \ + javax/swing/JTree.java javax/swing/JViewport.java \ + javax/swing/JWindow.java javax/swing/KeyStroke.java \ + javax/swing/ListCellRenderer.java javax/swing/ListModel.java \ + javax/swing/ListSelectionModel.java \ javax/swing/LookAndFeel.java javax/swing/Scrollable.java \ - javax/swing/Spring.java javax/swing/SpringLayout.java \ - javax/swing/SwingConstants.java \ + javax/swing/SpinnerModel.java \ + javax/swing/SpinnerNumberModel.java javax/swing/Spring.java \ + javax/swing/SpringLayout.java javax/swing/SwingConstants.java \ javax/swing/SwingUtilities.java javax/swing/Timer.java \ - javax/swing/UIDefaults.java javax/swing/UIManager.java \ + javax/swing/ToolTipManager.java \ + javax/swing/TransferHandler.java javax/swing/UIDefaults.java \ + javax/swing/UIManager.java \ javax/swing/UnsupportedLookAndFeelException.java \ javax/swing/event/AncestorEvent.java \ javax/swing/event/AncestorListener.java \ @@ -1735,12 +1759,17 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/text/NavigationFilter.java \ javax/swing/text/PlainDocument.java \ javax/swing/text/PlainView.java javax/swing/text/Position.java \ - javax/swing/text/Segment.java javax/swing/text/Style.java \ + javax/swing/text/Segment.java \ + javax/swing/text/SimpleAttributeSet.java \ + javax/swing/text/Style.java \ + javax/swing/text/StyleConstants.java \ + javax/swing/text/StyleContext.java \ javax/swing/text/StyledDocument.java \ javax/swing/text/StyledEditorKit.java \ - javax/swing/text/TabExpander.java \ javax/swing/text/TabableView.java \ - javax/swing/text/TextAction.java javax/swing/text/View.java \ + javax/swing/text/TabExpander.java javax/swing/text/TabSet.java \ + javax/swing/text/TabStop.java javax/swing/text/TextAction.java \ + javax/swing/text/Utilities.java javax/swing/text/View.java \ javax/swing/text/ViewFactory.java \ javax/swing/text/html/HTML.java \ javax/swing/text/html/parser/ParserDelegator.java \ @@ -1807,7 +1836,6 @@ am__libgcj_la_SOURCES_DIST = prims.cc jni.cc exception.cc resolve.cc \ javax/swing/ProgressMonitorInputStream.java \ javax/swing/RepaintManager.java \ javax/swing/ScrollPaneLayout.java \ - javax/swing/ToolTipManager.java \ javax/swing/ViewportLayout.java \ gnu/gcj/convert/BytesToUnicode.java \ gnu/gcj/convert/Convert.java gnu/gcj/convert/Input_8859_1.java \ @@ -2679,12 +2707,19 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/border/SoftBevelBorder.lo \ javax/swing/border/TitledBorder.lo javax/swing/GrayFilter.lo \ javax/swing/AbstractAction.lo javax/swing/AbstractButton.lo \ + javax/swing/AbstractSpinnerModel.lo \ javax/swing/plaf/basic/BasicArrowButton.lo \ javax/swing/plaf/basic/BasicButtonListener.lo \ javax/swing/plaf/basic/BasicButtonUI.lo \ javax/swing/plaf/basic/BasicCheckBoxUI.lo \ + javax/swing/plaf/basic/BasicColorChooserUI.lo \ + javax/swing/plaf/basic/BasicComboBoxUI.lo \ + javax/swing/plaf/basic/BasicComboBoxEditor.lo \ + javax/swing/plaf/basic/BasicComboBoxRenderer.lo \ + javax/swing/plaf/basic/BasicComboPopup.lo \ javax/swing/plaf/basic/BasicDesktopIconUI.lo \ javax/swing/plaf/basic/BasicDesktopPaneUI.lo \ + javax/swing/plaf/basic/BasicFormattedTextFieldUI.lo \ javax/swing/plaf/basic/BasicGraphicsUtils.lo \ javax/swing/plaf/basic/BasicInternalFrameTitlePane.lo \ javax/swing/plaf/basic/BasicInternalFrameUI.lo \ @@ -2695,6 +2730,7 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/plaf/basic/BasicMenuItemUI.lo \ javax/swing/plaf/basic/BasicOptionPaneUI.lo \ javax/swing/plaf/basic/BasicPanelUI.lo \ + javax/swing/plaf/basic/BasicPasswordFieldUI.lo \ javax/swing/plaf/basic/BasicPopupMenuUI.lo \ javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.lo \ javax/swing/plaf/basic/BasicProgressBarUI.lo \ @@ -2706,19 +2742,25 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/plaf/basic/BasicScrollPaneUI.lo \ javax/swing/plaf/basic/BasicSeparatorUI.lo \ javax/swing/plaf/basic/BasicSliderUI.lo \ + javax/swing/plaf/basic/BasicSpinnerUI.lo \ javax/swing/plaf/basic/BasicSplitPaneDivider.lo \ javax/swing/plaf/basic/BasicSplitPaneUI.lo \ javax/swing/plaf/basic/BasicTabbedPaneUI.lo \ + javax/swing/plaf/basic/BasicTableUI.lo \ + javax/swing/plaf/basic/BasicTableHeaderUI.lo \ + javax/swing/plaf/basic/BasicTextAreaUI.lo \ javax/swing/plaf/basic/BasicTextFieldUI.lo \ javax/swing/plaf/basic/BasicTextUI.lo \ javax/swing/plaf/basic/BasicToggleButtonUI.lo \ javax/swing/plaf/basic/BasicToolBarSeparatorUI.lo \ javax/swing/plaf/basic/BasicToolBarUI.lo \ + javax/swing/plaf/basic/BasicToolTipUI.lo \ javax/swing/plaf/basic/BasicTreeUI.lo \ javax/swing/plaf/basic/BasicViewportUI.lo \ javax/swing/plaf/basic/BasicLookAndFeel.lo \ javax/swing/plaf/basic/BasicBorders.lo \ javax/swing/plaf/basic/BasicIconFactory.lo \ + javax/swing/plaf/basic/ComboPopup.lo \ javax/swing/plaf/BorderUIResource.lo \ javax/swing/plaf/UIResource.lo javax/swing/plaf/ButtonUI.lo \ javax/swing/plaf/ComponentUI.lo javax/swing/plaf/LabelUI.lo \ @@ -2754,6 +2796,10 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/colorchooser/ColorChooserComponentFactory.lo \ javax/swing/colorchooser/ColorSelectionModel.lo \ javax/swing/colorchooser/DefaultColorSelectionModel.lo \ + javax/swing/colorchooser/DefaultPreviewPanel.lo \ + javax/swing/colorchooser/DefaultSwatchChooserPanel.lo \ + javax/swing/colorchooser/DefaultHSBChooserPanel.lo \ + javax/swing/colorchooser/DefaultRGBChooserPanel.lo \ javax/swing/filechooser/FileFilter.lo \ javax/swing/filechooser/FileSystemView.lo \ javax/swing/filechooser/FileView.lo \ @@ -2785,17 +2831,19 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/JOptionPane.lo javax/swing/JPanel.lo \ javax/swing/JRadioButton.lo javax/swing/JRootPane.lo \ javax/swing/JScrollBar.lo javax/swing/JScrollPane.lo \ - javax/swing/JTabbedPane.lo javax/swing/JTextArea.lo \ - javax/swing/JTextField.lo javax/swing/JToggleButton.lo \ - javax/swing/JToolTip.lo javax/swing/JTree.lo \ - javax/swing/JViewport.lo javax/swing/JWindow.lo \ - javax/swing/KeyStroke.lo javax/swing/ListCellRenderer.lo \ - javax/swing/ListModel.lo javax/swing/ListSelectionModel.lo \ - javax/swing/LookAndFeel.lo javax/swing/Scrollable.lo \ - javax/swing/Spring.lo javax/swing/SpringLayout.lo \ - javax/swing/SwingConstants.lo javax/swing/SwingUtilities.lo \ - javax/swing/Timer.lo javax/swing/UIDefaults.lo \ - javax/swing/UIManager.lo \ + javax/swing/JSpinner.lo javax/swing/JTabbedPane.lo \ + javax/swing/JTextArea.lo javax/swing/JTextField.lo \ + javax/swing/JToggleButton.lo javax/swing/JToolTip.lo \ + javax/swing/JTree.lo javax/swing/JViewport.lo \ + javax/swing/JWindow.lo javax/swing/KeyStroke.lo \ + javax/swing/ListCellRenderer.lo javax/swing/ListModel.lo \ + javax/swing/ListSelectionModel.lo javax/swing/LookAndFeel.lo \ + javax/swing/Scrollable.lo javax/swing/SpinnerModel.lo \ + javax/swing/SpinnerNumberModel.lo javax/swing/Spring.lo \ + javax/swing/SpringLayout.lo javax/swing/SwingConstants.lo \ + javax/swing/SwingUtilities.lo javax/swing/Timer.lo \ + javax/swing/ToolTipManager.lo javax/swing/TransferHandler.lo \ + javax/swing/UIDefaults.lo javax/swing/UIManager.lo \ javax/swing/UnsupportedLookAndFeelException.lo \ javax/swing/event/AncestorEvent.lo \ javax/swing/event/AncestorListener.lo \ @@ -2858,13 +2906,17 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/text/NavigationFilter.lo \ javax/swing/text/PlainDocument.lo \ javax/swing/text/PlainView.lo javax/swing/text/Position.lo \ - javax/swing/text/Segment.lo javax/swing/text/Style.lo \ + javax/swing/text/Segment.lo \ + javax/swing/text/SimpleAttributeSet.lo \ + javax/swing/text/Style.lo javax/swing/text/StyleConstants.lo \ + javax/swing/text/StyleContext.lo \ javax/swing/text/StyledDocument.lo \ javax/swing/text/StyledEditorKit.lo \ - javax/swing/text/TabExpander.lo \ - javax/swing/text/TabableView.lo javax/swing/text/TextAction.lo \ - javax/swing/text/View.lo javax/swing/text/ViewFactory.lo \ - javax/swing/text/html/HTML.lo \ + javax/swing/text/TabableView.lo \ + javax/swing/text/TabExpander.lo javax/swing/text/TabSet.lo \ + javax/swing/text/TabStop.lo javax/swing/text/TextAction.lo \ + javax/swing/text/Utilities.lo javax/swing/text/View.lo \ + javax/swing/text/ViewFactory.lo javax/swing/text/html/HTML.lo \ javax/swing/text/html/parser/ParserDelegator.lo \ javax/swing/tree/TreeNode.lo \ javax/swing/tree/AbstractLayoutCache.lo \ @@ -2923,7 +2975,7 @@ am__objects_11 = gnu/awt/LightweightRedirector.lo \ javax/swing/PopupFactory.lo javax/swing/ProgressMonitor.lo \ javax/swing/ProgressMonitorInputStream.lo \ javax/swing/RepaintManager.lo javax/swing/ScrollPaneLayout.lo \ - javax/swing/ToolTipManager.lo javax/swing/ViewportLayout.lo + javax/swing/ViewportLayout.lo am__objects_12 = gnu/gcj/convert/BytesToUnicode.lo \ gnu/gcj/convert/Convert.lo gnu/gcj/convert/Input_8859_1.lo \ gnu/gcj/convert/Input_ASCII.lo gnu/gcj/convert/Input_EUCJIS.lo \ @@ -4180,6 +4232,7 @@ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c \ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c \ +jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \ jni/gtk-peer/gthread-jni.c \ jni/classpath/jcl.c \ jni/classpath/jnilink.c \ @@ -4195,8 +4248,6 @@ gnu/java/awt/peer/gtk/GdkGraphics.java \ gnu/java/awt/peer/gtk/GdkGraphics2D.java \ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \ gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \ -gnu/java/awt/peer/gtk/GtkArg.java \ -gnu/java/awt/peer/gtk/GtkArgList.java \ gnu/java/awt/peer/gtk/GtkButtonPeer.java \ gnu/java/awt/peer/gtk/GtkCanvasPeer.java \ gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \ @@ -4230,7 +4281,9 @@ gnu/java/awt/peer/gtk/GtkTextAreaPeer.java \ gnu/java/awt/peer/gtk/GtkTextComponentPeer.java \ gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \ gnu/java/awt/peer/gtk/GtkToolkit.java \ -gnu/java/awt/peer/gtk/GtkWindowPeer.java +gnu/java/awt/peer/gtk/GtkWindowPeer.java \ +gnu/java/awt/peer/gtk/GThreadMutex.java \ +gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java gtk_jni_headers = $(patsubst %.java,jniinclude/%.h,$(subst /,_,$(gtk_awt_peer_sources))) lib_gnu_java_awt_peer_gtk_la_SOURCES = \ @@ -4245,7 +4298,8 @@ jni/classpath/primlib.h lib_gnu_java_awt_peer_gtk_la_CFLAGS = \ -Ijniinclude -I$(srcdir)/jni/classpath \ - -I$(srcdir)/jni/gtk-peer $(GTK_CFLAGS) $(LIBART_CFLAGS) + -I$(srcdir)/jni/gtk-peer $(PEDANTIC_CFLAGS) $(GTK_CFLAGS) $(LIBART_CFLAGS) \ + $(CAIRO_CFLAGS) $(PANGOFT2_CFLAGS) lib_gnu_java_awt_peer_gtk_la_GCJFLAGS = $(AM_GCJFLAGS) -fjni lib_gnu_java_awt_peer_gtk_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBART_LIBS) $(CAIRO_LIBS) $(PANGOFT2_LIBS) @@ -4846,12 +4900,19 @@ javax/swing/border/TitledBorder.java \ javax/swing/GrayFilter.java \ javax/swing/AbstractAction.java \ javax/swing/AbstractButton.java \ +javax/swing/AbstractSpinnerModel.java \ javax/swing/plaf/basic/BasicArrowButton.java \ javax/swing/plaf/basic/BasicButtonListener.java \ javax/swing/plaf/basic/BasicButtonUI.java \ javax/swing/plaf/basic/BasicCheckBoxUI.java \ +javax/swing/plaf/basic/BasicColorChooserUI.java \ +javax/swing/plaf/basic/BasicComboBoxUI.java \ +javax/swing/plaf/basic/BasicComboBoxEditor.java \ +javax/swing/plaf/basic/BasicComboBoxRenderer.java \ +javax/swing/plaf/basic/BasicComboPopup.java \ javax/swing/plaf/basic/BasicDesktopIconUI.java \ javax/swing/plaf/basic/BasicDesktopPaneUI.java \ +javax/swing/plaf/basic/BasicFormattedTextFieldUI.java \ javax/swing/plaf/basic/BasicGraphicsUtils.java \ javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \ javax/swing/plaf/basic/BasicInternalFrameUI.java \ @@ -4862,6 +4923,7 @@ javax/swing/plaf/basic/BasicMenuBarUI.java \ javax/swing/plaf/basic/BasicMenuItemUI.java \ javax/swing/plaf/basic/BasicOptionPaneUI.java \ javax/swing/plaf/basic/BasicPanelUI.java \ +javax/swing/plaf/basic/BasicPasswordFieldUI.java \ javax/swing/plaf/basic/BasicPopupMenuUI.java \ javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \ javax/swing/plaf/basic/BasicProgressBarUI.java \ @@ -4873,19 +4935,25 @@ javax/swing/plaf/basic/BasicScrollBarUI.java \ javax/swing/plaf/basic/BasicScrollPaneUI.java \ javax/swing/plaf/basic/BasicSeparatorUI.java \ javax/swing/plaf/basic/BasicSliderUI.java \ +javax/swing/plaf/basic/BasicSpinnerUI.java \ javax/swing/plaf/basic/BasicSplitPaneDivider.java \ javax/swing/plaf/basic/BasicSplitPaneUI.java \ javax/swing/plaf/basic/BasicTabbedPaneUI.java \ +javax/swing/plaf/basic/BasicTableUI.java \ +javax/swing/plaf/basic/BasicTableHeaderUI.java \ +javax/swing/plaf/basic/BasicTextAreaUI.java \ javax/swing/plaf/basic/BasicTextFieldUI.java \ javax/swing/plaf/basic/BasicTextUI.java \ javax/swing/plaf/basic/BasicToggleButtonUI.java \ javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \ javax/swing/plaf/basic/BasicToolBarUI.java \ +javax/swing/plaf/basic/BasicToolTipUI.java \ javax/swing/plaf/basic/BasicTreeUI.java \ javax/swing/plaf/basic/BasicViewportUI.java \ javax/swing/plaf/basic/BasicLookAndFeel.java \ javax/swing/plaf/basic/BasicBorders.java \ javax/swing/plaf/basic/BasicIconFactory.java \ +javax/swing/plaf/basic/ComboPopup.java \ javax/swing/plaf/BorderUIResource.java \ javax/swing/plaf/UIResource.java \ javax/swing/plaf/ButtonUI.java \ @@ -4934,6 +5002,10 @@ javax/swing/colorchooser/AbstractColorChooserPanel.java \ javax/swing/colorchooser/ColorChooserComponentFactory.java \ javax/swing/colorchooser/ColorSelectionModel.java \ javax/swing/colorchooser/DefaultColorSelectionModel.java \ +javax/swing/colorchooser/DefaultPreviewPanel.java \ +javax/swing/colorchooser/DefaultSwatchChooserPanel.java \ +javax/swing/colorchooser/DefaultHSBChooserPanel.java \ +javax/swing/colorchooser/DefaultRGBChooserPanel.java \ javax/swing/filechooser/FileFilter.java \ javax/swing/filechooser/FileSystemView.java \ javax/swing/filechooser/FileView.java \ @@ -4979,6 +5051,7 @@ javax/swing/JRadioButton.java \ javax/swing/JRootPane.java \ javax/swing/JScrollBar.java \ javax/swing/JScrollPane.java \ +javax/swing/JSpinner.java \ javax/swing/JTabbedPane.java \ javax/swing/JTextArea.java \ javax/swing/JTextField.java \ @@ -4993,11 +5066,15 @@ javax/swing/ListModel.java \ javax/swing/ListSelectionModel.java \ javax/swing/LookAndFeel.java \ javax/swing/Scrollable.java \ +javax/swing/SpinnerModel.java \ +javax/swing/SpinnerNumberModel.java \ javax/swing/Spring.java \ javax/swing/SpringLayout.java \ javax/swing/SwingConstants.java \ javax/swing/SwingUtilities.java \ javax/swing/Timer.java \ +javax/swing/ToolTipManager.java \ +javax/swing/TransferHandler.java \ javax/swing/UIDefaults.java \ javax/swing/UIManager.java \ javax/swing/UnsupportedLookAndFeelException.java \ @@ -5069,12 +5146,18 @@ javax/swing/text/PlainDocument.java \ javax/swing/text/PlainView.java \ javax/swing/text/Position.java \ javax/swing/text/Segment.java \ +javax/swing/text/SimpleAttributeSet.java \ javax/swing/text/Style.java \ +javax/swing/text/StyleConstants.java \ +javax/swing/text/StyleContext.java \ javax/swing/text/StyledDocument.java \ javax/swing/text/StyledEditorKit.java \ -javax/swing/text/TabExpander.java \ javax/swing/text/TabableView.java \ +javax/swing/text/TabExpander.java \ +javax/swing/text/TabSet.java \ +javax/swing/text/TabStop.java \ javax/swing/text/TextAction.java \ +javax/swing/text/Utilities.java \ javax/swing/text/View.java \ javax/swing/text/ViewFactory.java \ javax/swing/text/html/HTML.java \ @@ -5157,7 +5240,6 @@ javax/swing/ProgressMonitor.java \ javax/swing/ProgressMonitorInputStream.java \ javax/swing/RepaintManager.java \ javax/swing/ScrollPaneLayout.java \ -javax/swing/ToolTipManager.java \ javax/swing/ViewportLayout.java rmi_java_source_files = \ @@ -6841,12 +6923,6 @@ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkGraphicsEnvironment.lo: \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.lo: \ gnu/java/awt/peer/gtk/$(am__dirstamp) \ gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) -gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo: \ - gnu/java/awt/peer/gtk/$(am__dirstamp) \ - gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) -gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo: \ - gnu/java/awt/peer/gtk/$(am__dirstamp) \ - gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo: \ gnu/java/awt/peer/gtk/$(am__dirstamp) \ gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) @@ -6949,6 +7025,12 @@ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkToolkit.lo: \ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkWindowPeer.lo: \ gnu/java/awt/peer/gtk/$(am__dirstamp) \ gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) +gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo: \ + gnu/java/awt/peer/gtk/$(am__dirstamp) \ + gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) +gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo: \ + gnu/java/awt/peer/gtk/$(am__dirstamp) \ + gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) jni/gtk-peer/$(am__dirstamp): @$(mkdir_p) jni/gtk-peer @: > jni/gtk-peer/$(am__dirstamp) @@ -7063,6 +7145,9 @@ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkToolkit.lo: jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkWindowPeer.lo: \ jni/gtk-peer/$(am__dirstamp) \ jni/gtk-peer/$(DEPDIR)/$(am__dirstamp) +jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo: \ + jni/gtk-peer/$(am__dirstamp) \ + jni/gtk-peer/$(DEPDIR)/$(am__dirstamp) jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gthread-jni.lo: \ jni/gtk-peer/$(am__dirstamp) \ jni/gtk-peer/$(DEPDIR)/$(am__dirstamp) @@ -11244,6 +11329,8 @@ javax/swing/AbstractAction.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/AbstractButton.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/AbstractSpinnerModel.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/$(am__dirstamp): @$(mkdir_p) javax/swing/plaf/basic @: > javax/swing/plaf/basic/$(am__dirstamp) @@ -11262,12 +11349,30 @@ javax/swing/plaf/basic/BasicButtonUI.lo: \ javax/swing/plaf/basic/BasicCheckBoxUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicColorChooserUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicComboBoxUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicComboBoxEditor.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicComboBoxRenderer.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicComboPopup.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicDesktopIconUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicDesktopPaneUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicFormattedTextFieldUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicGraphicsUtils.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) @@ -11298,6 +11403,9 @@ javax/swing/plaf/basic/BasicOptionPaneUI.lo: \ javax/swing/plaf/basic/BasicPanelUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicPasswordFieldUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicPopupMenuUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) @@ -11331,6 +11439,9 @@ javax/swing/plaf/basic/BasicSeparatorUI.lo: \ javax/swing/plaf/basic/BasicSliderUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicSpinnerUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicSplitPaneDivider.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) @@ -11340,6 +11451,15 @@ javax/swing/plaf/basic/BasicSplitPaneUI.lo: \ javax/swing/plaf/basic/BasicTabbedPaneUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicTableUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicTableHeaderUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicTextAreaUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicTextFieldUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) @@ -11355,6 +11475,9 @@ javax/swing/plaf/basic/BasicToolBarSeparatorUI.lo: \ javax/swing/plaf/basic/BasicToolBarUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/BasicToolTipUI.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/basic/BasicTreeUI.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) @@ -11370,6 +11493,9 @@ javax/swing/plaf/basic/BasicBorders.lo: \ javax/swing/plaf/basic/BasicIconFactory.lo: \ javax/swing/plaf/basic/$(am__dirstamp) \ javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) +javax/swing/plaf/basic/ComboPopup.lo: \ + javax/swing/plaf/basic/$(am__dirstamp) \ + javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) javax/swing/plaf/$(am__dirstamp): @$(mkdir_p) javax/swing/plaf @: > javax/swing/plaf/$(am__dirstamp) @@ -11495,6 +11621,18 @@ javax/swing/colorchooser/ColorSelectionModel.lo: \ javax/swing/colorchooser/DefaultColorSelectionModel.lo: \ javax/swing/colorchooser/$(am__dirstamp) \ javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) +javax/swing/colorchooser/DefaultPreviewPanel.lo: \ + javax/swing/colorchooser/$(am__dirstamp) \ + javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) +javax/swing/colorchooser/DefaultSwatchChooserPanel.lo: \ + javax/swing/colorchooser/$(am__dirstamp) \ + javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) +javax/swing/colorchooser/DefaultHSBChooserPanel.lo: \ + javax/swing/colorchooser/$(am__dirstamp) \ + javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) +javax/swing/colorchooser/DefaultRGBChooserPanel.lo: \ + javax/swing/colorchooser/$(am__dirstamp) \ + javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) javax/swing/filechooser/$(am__dirstamp): @$(mkdir_p) javax/swing/filechooser @: > javax/swing/filechooser/$(am__dirstamp) @@ -11607,6 +11745,8 @@ javax/swing/JScrollBar.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/JScrollPane.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/JSpinner.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/JTabbedPane.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/JTextArea.lo: javax/swing/$(am__dirstamp) \ @@ -11635,6 +11775,10 @@ javax/swing/LookAndFeel.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/Scrollable.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/SpinnerModel.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/SpinnerNumberModel.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/Spring.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/SpringLayout.lo: javax/swing/$(am__dirstamp) \ @@ -11645,6 +11789,10 @@ javax/swing/SwingUtilities.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/Timer.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/ToolTipManager.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) +javax/swing/TransferHandler.lo: javax/swing/$(am__dirstamp) \ + javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/UIDefaults.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/UIManager.lo: javax/swing/$(am__dirstamp) \ @@ -11841,18 +11989,31 @@ javax/swing/text/Position.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/Segment.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/SimpleAttributeSet.lo: \ + javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/Style.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/StyleConstants.lo: javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/StyleContext.lo: javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/StyledDocument.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/StyledEditorKit.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/TabableView.lo: javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/TabExpander.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) -javax/swing/text/TabableView.lo: javax/swing/text/$(am__dirstamp) \ +javax/swing/text/TabSet.lo: javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/TabStop.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/TextAction.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) +javax/swing/text/Utilities.lo: javax/swing/text/$(am__dirstamp) \ + javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/View.lo: javax/swing/text/$(am__dirstamp) \ javax/swing/text/$(DEPDIR)/$(am__dirstamp) javax/swing/text/ViewFactory.lo: javax/swing/text/$(am__dirstamp) \ @@ -12059,8 +12220,6 @@ javax/swing/RepaintManager.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/ScrollPaneLayout.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) -javax/swing/ToolTipManager.lo: javax/swing/$(am__dirstamp) \ - javax/swing/$(DEPDIR)/$(am__dirstamp) javax/swing/ViewportLayout.lo: javax/swing/$(am__dirstamp) \ javax/swing/$(DEPDIR)/$(am__dirstamp) gnu/gcj/convert/BytesToUnicode.lo: gnu/gcj/convert/$(am__dirstamp) \ @@ -13308,6 +13467,10 @@ mostlyclean-compile: -rm -f gnu/java/awt/peer/EmbeddedWindowPeer.lo -rm -f gnu/java/awt/peer/GLightweightPeer.$(OBJEXT) -rm -f gnu/java/awt/peer/GLightweightPeer.lo + -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.$(OBJEXT) + -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo + -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.$(OBJEXT) + -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkClasspathFontPeer.$(OBJEXT) -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkClasspathFontPeer.lo -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkClasspathFontPeerMetrics.$(OBJEXT) @@ -13324,10 +13487,6 @@ mostlyclean-compile: -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkGraphicsEnvironment.lo -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.$(OBJEXT) -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.lo - -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.$(OBJEXT) - -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo - -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.$(OBJEXT) - -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.$(OBJEXT) -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo -rm -f gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkCanvasPeer.$(OBJEXT) @@ -16786,6 +16945,8 @@ mostlyclean-compile: -rm -f javax/swing/AbstractListModel.lo -rm -f javax/swing/AbstractSet.$(OBJEXT) -rm -f javax/swing/AbstractSet.lo + -rm -f javax/swing/AbstractSpinnerModel.$(OBJEXT) + -rm -f javax/swing/AbstractSpinnerModel.lo -rm -f javax/swing/Action.$(OBJEXT) -rm -f javax/swing/Action.lo -rm -f javax/swing/ActionMap.$(OBJEXT) @@ -16914,6 +17075,8 @@ mostlyclean-compile: -rm -f javax/swing/JSeparator.lo -rm -f javax/swing/JSlider.$(OBJEXT) -rm -f javax/swing/JSlider.lo + -rm -f javax/swing/JSpinner.$(OBJEXT) + -rm -f javax/swing/JSpinner.lo -rm -f javax/swing/JSplitPane.$(OBJEXT) -rm -f javax/swing/JSplitPane.lo -rm -f javax/swing/JTabbedPane.$(OBJEXT) @@ -16982,6 +17145,10 @@ mostlyclean-compile: -rm -f javax/swing/SizeRequirements.lo -rm -f javax/swing/SizeSequence.$(OBJEXT) -rm -f javax/swing/SizeSequence.lo + -rm -f javax/swing/SpinnerModel.$(OBJEXT) + -rm -f javax/swing/SpinnerModel.lo + -rm -f javax/swing/SpinnerNumberModel.$(OBJEXT) + -rm -f javax/swing/SpinnerNumberModel.lo -rm -f javax/swing/Spring.$(OBJEXT) -rm -f javax/swing/Spring.lo -rm -f javax/swing/SpringLayout.$(OBJEXT) @@ -16994,6 +17161,8 @@ mostlyclean-compile: -rm -f javax/swing/Timer.lo -rm -f javax/swing/ToolTipManager.$(OBJEXT) -rm -f javax/swing/ToolTipManager.lo + -rm -f javax/swing/TransferHandler.$(OBJEXT) + -rm -f javax/swing/TransferHandler.lo -rm -f javax/swing/UIDefaults.$(OBJEXT) -rm -f javax/swing/UIDefaults.lo -rm -f javax/swing/UIManager.$(OBJEXT) @@ -17032,6 +17201,14 @@ mostlyclean-compile: -rm -f javax/swing/colorchooser/ColorSelectionModel.lo -rm -f javax/swing/colorchooser/DefaultColorSelectionModel.$(OBJEXT) -rm -f javax/swing/colorchooser/DefaultColorSelectionModel.lo + -rm -f javax/swing/colorchooser/DefaultHSBChooserPanel.$(OBJEXT) + -rm -f javax/swing/colorchooser/DefaultHSBChooserPanel.lo + -rm -f javax/swing/colorchooser/DefaultPreviewPanel.$(OBJEXT) + -rm -f javax/swing/colorchooser/DefaultPreviewPanel.lo + -rm -f javax/swing/colorchooser/DefaultRGBChooserPanel.$(OBJEXT) + -rm -f javax/swing/colorchooser/DefaultRGBChooserPanel.lo + -rm -f javax/swing/colorchooser/DefaultSwatchChooserPanel.$(OBJEXT) + -rm -f javax/swing/colorchooser/DefaultSwatchChooserPanel.lo -rm -f javax/swing/event/AncestorEvent.$(OBJEXT) -rm -f javax/swing/event/AncestorEvent.lo -rm -f javax/swing/event/AncestorListener.$(OBJEXT) @@ -17218,10 +17395,22 @@ mostlyclean-compile: -rm -f javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.lo -rm -f javax/swing/plaf/basic/BasicCheckBoxUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicCheckBoxUI.lo + -rm -f javax/swing/plaf/basic/BasicColorChooserUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicColorChooserUI.lo + -rm -f javax/swing/plaf/basic/BasicComboBoxEditor.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicComboBoxEditor.lo + -rm -f javax/swing/plaf/basic/BasicComboBoxRenderer.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicComboBoxRenderer.lo + -rm -f javax/swing/plaf/basic/BasicComboBoxUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicComboBoxUI.lo + -rm -f javax/swing/plaf/basic/BasicComboPopup.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicComboPopup.lo -rm -f javax/swing/plaf/basic/BasicDesktopIconUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicDesktopIconUI.lo -rm -f javax/swing/plaf/basic/BasicDesktopPaneUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicDesktopPaneUI.lo + -rm -f javax/swing/plaf/basic/BasicFormattedTextFieldUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicFormattedTextFieldUI.lo -rm -f javax/swing/plaf/basic/BasicGraphicsUtils.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicGraphicsUtils.lo -rm -f javax/swing/plaf/basic/BasicIconFactory.$(OBJEXT) @@ -17246,6 +17435,8 @@ mostlyclean-compile: -rm -f javax/swing/plaf/basic/BasicOptionPaneUI.lo -rm -f javax/swing/plaf/basic/BasicPanelUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicPanelUI.lo + -rm -f javax/swing/plaf/basic/BasicPasswordFieldUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicPasswordFieldUI.lo -rm -f javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.lo -rm -f javax/swing/plaf/basic/BasicPopupMenuUI.$(OBJEXT) @@ -17266,12 +17457,20 @@ mostlyclean-compile: -rm -f javax/swing/plaf/basic/BasicSeparatorUI.lo -rm -f javax/swing/plaf/basic/BasicSliderUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicSliderUI.lo + -rm -f javax/swing/plaf/basic/BasicSpinnerUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicSpinnerUI.lo -rm -f javax/swing/plaf/basic/BasicSplitPaneDivider.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicSplitPaneDivider.lo -rm -f javax/swing/plaf/basic/BasicSplitPaneUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicSplitPaneUI.lo -rm -f javax/swing/plaf/basic/BasicTabbedPaneUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicTabbedPaneUI.lo + -rm -f javax/swing/plaf/basic/BasicTableHeaderUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicTableHeaderUI.lo + -rm -f javax/swing/plaf/basic/BasicTableUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicTableUI.lo + -rm -f javax/swing/plaf/basic/BasicTextAreaUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicTextAreaUI.lo -rm -f javax/swing/plaf/basic/BasicTextFieldUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicTextFieldUI.lo -rm -f javax/swing/plaf/basic/BasicTextUI.$(OBJEXT) @@ -17282,10 +17481,14 @@ mostlyclean-compile: -rm -f javax/swing/plaf/basic/BasicToolBarSeparatorUI.lo -rm -f javax/swing/plaf/basic/BasicToolBarUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicToolBarUI.lo + -rm -f javax/swing/plaf/basic/BasicToolTipUI.$(OBJEXT) + -rm -f javax/swing/plaf/basic/BasicToolTipUI.lo -rm -f javax/swing/plaf/basic/BasicTreeUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicTreeUI.lo -rm -f javax/swing/plaf/basic/BasicViewportUI.$(OBJEXT) -rm -f javax/swing/plaf/basic/BasicViewportUI.lo + -rm -f javax/swing/plaf/basic/ComboPopup.$(OBJEXT) + -rm -f javax/swing/plaf/basic/ComboPopup.lo -rm -f javax/swing/plaf/metal/MetalLookAndFeel.$(OBJEXT) -rm -f javax/swing/plaf/metal/MetalLookAndFeel.lo -rm -f javax/swing/table/AbstractTableModel.$(OBJEXT) @@ -17356,18 +17559,30 @@ mostlyclean-compile: -rm -f javax/swing/text/Position.lo -rm -f javax/swing/text/Segment.$(OBJEXT) -rm -f javax/swing/text/Segment.lo + -rm -f javax/swing/text/SimpleAttributeSet.$(OBJEXT) + -rm -f javax/swing/text/SimpleAttributeSet.lo -rm -f javax/swing/text/Style.$(OBJEXT) -rm -f javax/swing/text/Style.lo + -rm -f javax/swing/text/StyleConstants.$(OBJEXT) + -rm -f javax/swing/text/StyleConstants.lo + -rm -f javax/swing/text/StyleContext.$(OBJEXT) + -rm -f javax/swing/text/StyleContext.lo -rm -f javax/swing/text/StyledDocument.$(OBJEXT) -rm -f javax/swing/text/StyledDocument.lo -rm -f javax/swing/text/StyledEditorKit.$(OBJEXT) -rm -f javax/swing/text/StyledEditorKit.lo -rm -f javax/swing/text/TabExpander.$(OBJEXT) -rm -f javax/swing/text/TabExpander.lo + -rm -f javax/swing/text/TabSet.$(OBJEXT) + -rm -f javax/swing/text/TabSet.lo + -rm -f javax/swing/text/TabStop.$(OBJEXT) + -rm -f javax/swing/text/TabStop.lo -rm -f javax/swing/text/TabableView.$(OBJEXT) -rm -f javax/swing/text/TabableView.lo -rm -f javax/swing/text/TextAction.$(OBJEXT) -rm -f javax/swing/text/TextAction.lo + -rm -f javax/swing/text/Utilities.$(OBJEXT) + -rm -f javax/swing/text/Utilities.lo -rm -f javax/swing/text/View.$(OBJEXT) -rm -f javax/swing/text/View.lo -rm -f javax/swing/text/ViewFactory.$(OBJEXT) @@ -17470,6 +17685,8 @@ mostlyclean-compile: -rm -f jni/classpath/lib_gnu_java_awt_peer_gtk_la-native_state.lo -rm -f jni/classpath/lib_gnu_java_awt_peer_gtk_la-primlib.$(OBJEXT) -rm -f jni/classpath/lib_gnu_java_awt_peer_gtk_la-primlib.lo + -rm -f jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.$(OBJEXT) + -rm -f jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo -rm -f jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeer.$(OBJEXT) -rm -f jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeer.lo -rm -f jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.$(OBJEXT) @@ -17806,6 +18023,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/$(DEPDIR)/ClasspathFontPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/$(DEPDIR)/EmbeddedWindowPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/$(DEPDIR)/GLightweightPeer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkClasspathFontPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkClasspathFontPeerMetrics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkFontMetrics.Plo@am__quote@ @@ -17814,8 +18033,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkGraphics2D.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkGraphicsEnvironment.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArg.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArgList.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkCanvasPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkCheckboxGroupPeer.Plo@am__quote@ @@ -19545,6 +19762,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/AbstractCellEditor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/AbstractListModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/AbstractSet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/AbstractSpinnerModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/Action.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/ActionMap.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/BorderFactory.Plo@am__quote@ @@ -19609,6 +19827,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JScrollPane.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JSeparator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JSlider.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JSpinner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JSplitPane.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JTabbedPane.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/JTable.Plo@am__quote@ @@ -19643,12 +19862,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SingleSelectionModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SizeRequirements.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SizeSequence.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SpinnerModel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SpinnerNumberModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/Spring.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SpringLayout.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SwingConstants.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/SwingUtilities.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/Timer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/ToolTipManager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/TransferHandler.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/UIDefaults.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/UIManager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/$(DEPDIR)/UnsupportedLookAndFeelException.Plo@am__quote@ @@ -19668,6 +19890,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/ColorChooserComponentFactory.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/ColorSelectionModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/DefaultColorSelectionModel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/DefaultHSBChooserPanel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/DefaultPreviewPanel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/DefaultRGBChooserPanel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/colorchooser/$(DEPDIR)/DefaultSwatchChooserPanel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/event/$(DEPDIR)/AncestorEvent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/event/$(DEPDIR)/AncestorListener.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/event/$(DEPDIR)/CaretEvent.Plo@am__quote@ @@ -19761,8 +19987,14 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicButtonUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicCheckBoxMenuItemUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicCheckBoxUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicColorChooserUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicComboBoxEditor.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicComboBoxRenderer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicComboBoxUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicComboPopup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicDesktopIconUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicDesktopPaneUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicFormattedTextFieldUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicGraphicsUtils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicIconFactory.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicInternalFrameTitlePane.Plo@am__quote@ @@ -19775,6 +20007,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicMenuUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicOptionPaneUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicPanelUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicPasswordFieldUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicPopupMenuSeparatorUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicPopupMenuUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicProgressBarUI.Plo@am__quote@ @@ -19785,16 +20018,22 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicScrollPaneUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicSeparatorUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicSliderUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicSpinnerUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicSplitPaneDivider.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicSplitPaneUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTabbedPaneUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTableHeaderUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTableUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTextAreaUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTextFieldUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTextUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicToggleButtonUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicToolBarSeparatorUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicToolBarUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicToolTipUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicTreeUI.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/BasicViewportUI.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/basic/$(DEPDIR)/ComboPopup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/plaf/metal/$(DEPDIR)/MetalLookAndFeel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/table/$(DEPDIR)/AbstractTableModel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/table/$(DEPDIR)/DefaultTableCellRenderer.Plo@am__quote@ @@ -19830,12 +20069,18 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/PlainView.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/Position.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/Segment.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/SimpleAttributeSet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/Style.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/StyleConstants.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/StyleContext.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/StyledDocument.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/StyledEditorKit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/TabExpander.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/TabSet.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/TabStop.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/TabableView.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/TextAction.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/Utilities.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/View.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/$(DEPDIR)/ViewFactory.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@javax/swing/text/html/$(DEPDIR)/HTML.Plo@am__quote@ @@ -19887,6 +20132,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@jni/classpath/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-jnilink.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@jni/classpath/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-native_state.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@jni/classpath/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-primlib.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GdkFontMetrics.Plo@am__quote@ @@ -20257,6 +20503,13 @@ jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkWindowPeer.lo @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_gnu_java_awt_peer_gtk_la_CFLAGS) $(CFLAGS) -c -o jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GtkWindowPeer.lo `test -f 'jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c' || echo '$(srcdir)/'`jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo: jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_gnu_java_awt_peer_gtk_la_CFLAGS) $(CFLAGS) -MT jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo -MD -MP -MF "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Tpo" -c -o jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo `test -f 'jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c' || echo '$(srcdir)/'`jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c; \ +@am__fastdepCC_TRUE@ then mv -f "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Tpo" "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Plo"; else rm -f "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c' object='jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_gnu_java_awt_peer_gtk_la_CFLAGS) $(CFLAGS) -c -o jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo `test -f 'jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c' || echo '$(srcdir)/'`jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c + jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gthread-jni.lo: jni/gtk-peer/gthread-jni.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_gnu_java_awt_peer_gtk_la_CFLAGS) $(CFLAGS) -MT jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gthread-jni.lo -MD -MP -MF "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gthread-jni.Tpo" -c -o jni/gtk-peer/lib_gnu_java_awt_peer_gtk_la-gthread-jni.lo `test -f 'jni/gtk-peer/gthread-jni.c' || echo '$(srcdir)/'`jni/gtk-peer/gthread-jni.c; \ @am__fastdepCC_TRUE@ then mv -f "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gthread-jni.Tpo" "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gthread-jni.Plo"; else rm -f "jni/gtk-peer/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-gthread-jni.Tpo"; exit 1; fi @@ -20396,20 +20649,6 @@ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.lo: gnu/java @AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GdkPixbufDecoder.lo `test -f 'gnu/java/awt/peer/gtk/GdkPixbufDecoder.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GdkPixbufDecoder.java -gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo: gnu/java/awt/peer/gtk/GtkArg.java -@am__fastdepGCJ_TRUE@ if $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -MT gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo -MD -MP -MF "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArg.Tpo" -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo `test -f 'gnu/java/awt/peer/gtk/GtkArg.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkArg.java; \ -@am__fastdepGCJ_TRUE@ then mv -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArg.Tpo" "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArg.Plo"; else rm -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArg.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ source='gnu/java/awt/peer/gtk/GtkArg.java' object='gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArg.lo `test -f 'gnu/java/awt/peer/gtk/GtkArg.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkArg.java - -gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo: gnu/java/awt/peer/gtk/GtkArgList.java -@am__fastdepGCJ_TRUE@ if $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -MT gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo -MD -MP -MF "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArgList.Tpo" -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo `test -f 'gnu/java/awt/peer/gtk/GtkArgList.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkArgList.java; \ -@am__fastdepGCJ_TRUE@ then mv -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArgList.Tpo" "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArgList.Plo"; else rm -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkArgList.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ source='gnu/java/awt/peer/gtk/GtkArgList.java' object='gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkArgList.lo `test -f 'gnu/java/awt/peer/gtk/GtkArgList.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkArgList.java - gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo: gnu/java/awt/peer/gtk/GtkButtonPeer.java @am__fastdepGCJ_TRUE@ if $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -MT gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo -MD -MP -MF "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.Tpo" -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.lo `test -f 'gnu/java/awt/peer/gtk/GtkButtonPeer.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkButtonPeer.java; \ @am__fastdepGCJ_TRUE@ then mv -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.Tpo" "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.Plo"; else rm -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GtkButtonPeer.Tpo"; exit 1; fi @@ -20648,6 +20887,20 @@ gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkWindowPeer.lo: gnu/java/aw @AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GtkWindowPeer.lo `test -f 'gnu/java/awt/peer/gtk/GtkWindowPeer.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GtkWindowPeer.java +gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo: gnu/java/awt/peer/gtk/GThreadMutex.java +@am__fastdepGCJ_TRUE@ if $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -MT gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo -MD -MP -MF "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.Tpo" -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo `test -f 'gnu/java/awt/peer/gtk/GThreadMutex.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GThreadMutex.java; \ +@am__fastdepGCJ_TRUE@ then mv -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.Tpo" "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.Plo"; else rm -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ source='gnu/java/awt/peer/gtk/GThreadMutex.java' object='gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadMutex.lo `test -f 'gnu/java/awt/peer/gtk/GThreadMutex.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GThreadMutex.java + +gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo: gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java +@am__fastdepGCJ_TRUE@ if $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -MT gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo -MD -MP -MF "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.Tpo" -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo `test -f 'gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java; \ +@am__fastdepGCJ_TRUE@ then mv -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.Tpo" "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.Plo"; else rm -f "gnu/java/awt/peer/gtk/$(DEPDIR)/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ source='gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java' object='gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepGCJ_FALSE@ DEPDIR=$(DEPDIR) $(GCJDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepGCJ_FALSE@ $(LIBTOOL) --mode=compile $(GCJ) $(lib_gnu_java_awt_peer_gtk_la_GCJFLAGS) $(GCJFLAGS) -c -o gnu/java/awt/peer/gtk/lib_gnu_java_awt_peer_gtk_la-GThreadNativeMethodRunner.lo `test -f 'gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java' || echo '$(srcdir)/'`gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java + mostlyclean-libtool: -rm -f *.lo @@ -21133,270 +21386,270 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -rm -f java/sql/$(DEPDIR)/$(am__dirstamp) - -rm -f java/nio/channels/spi/$(am__dirstamp) - -rm -f java/util/regex/$(am__dirstamp) - -rm -f javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/rmic/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/net/protocol/file/$(DEPDIR)/$(am__dirstamp) - -rm -f java/net/$(DEPDIR)/$(am__dirstamp) - -rm -f java/lang/ref/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/table/$(am__dirstamp) - -rm -f javax/swing/$(am__dirstamp) - -rm -f java/awt/datatransfer/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/tree/$(am__dirstamp) - -rm -f javax/swing/text/$(am__dirstamp) - -rm -f javax/naming/spi/$(am__dirstamp) - -rm -f javax/naming/ldap/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/attribute/standard/$(am__dirstamp) - -rm -f java/util/$(am__dirstamp) - -rm -f java/awt/dnd/peer/$(am__dirstamp) - -rm -f javax/print/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/tree/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/awt/$(am__dirstamp) - -rm -f java/applet/$(am__dirstamp) - -rm -f gnu/classpath/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/security/auth/x500/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/server/$(am__dirstamp) - -rm -f java/rmi/$(DEPDIR)/$(am__dirstamp) - -rm -f java/lang/ref/$(am__dirstamp) - -rm -f gnu/java/rmi/rmic/$(am__dirstamp) - -rm -f gnu/java/awt/image/$(am__dirstamp) - -rm -f gnu/java/net/protocol/jar/$(DEPDIR)/$(am__dirstamp) - -rm -f jni/gtk-peer/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/util/prefs/$(am__dirstamp) - -rm -f java/util/regex/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/util/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/awt/peer/$(am__dirstamp) - -rm -f java/awt/image/renderable/$(am__dirstamp) - -rm -f javax/transaction/xa/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/image/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/filechooser/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/datatransfer/$(am__dirstamp) - -rm -f gnu/java/beans/editors/$(am__dirstamp) - -rm -f java/awt/font/$(am__dirstamp) + -rm -f javax/naming/$(am__dirstamp) + -rm -f java/util/logging/$(DEPDIR)/$(am__dirstamp) + -rm -f java/beans/$(am__dirstamp) + -rm -f gnu/java/awt/$(am__dirstamp) + -rm -f javax/swing/border/$(DEPDIR)/$(am__dirstamp) + -rm -f org/w3c/dom/traversal/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/activation/$(am__dirstamp) + -rm -f java/security/interfaces/$(am__dirstamp) -rm -f gnu/java/locale/$(am__dirstamp) - -rm -f gnu/gcj/$(am__dirstamp) - -rm -f gnu/gcj/xlib/$(am__dirstamp) - -rm -f javax/naming/directory/$(am__dirstamp) + -rm -f gnu/java/beans/$(am__dirstamp) + -rm -f gnu/java/net/protocol/jar/$(am__dirstamp) -rm -f java/awt/$(am__dirstamp) - -rm -f gnu/java/rmi/dgc/$(am__dirstamp) - -rm -f java/security/cert/$(am__dirstamp) - -rm -f javax/swing/event/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/gcj/convert/$(am__dirstamp) - -rm -f gnu/java/security/$(DEPDIR)/$(am__dirstamp) - -rm -f java/util/zip/$(am__dirstamp) - -rm -f javax/swing/text/html/parser/$(am__dirstamp) -rm -f org/xml/sax/helpers/$(am__dirstamp) - -rm -f javax/swing/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/font/$(DEPDIR)/$(am__dirstamp) - -rm -f sysdep/$(am__dirstamp) - -rm -f javax/swing/text/html/$(DEPDIR)/$(am__dirstamp) + -rm -f org/xml/sax/ext/$(am__dirstamp) + -rm -f java/security/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/net/protocol/file/$(DEPDIR)/$(am__dirstamp) + -rm -f org/w3c/dom/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) + -rm -f java/util/prefs/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/lang/$(am__dirstamp) + -rm -f java/lang/reflect/$(am__dirstamp) + -rm -f java/math/$(am__dirstamp) + -rm -f gnu/java/net/protocol/file/$(am__dirstamp) + -rm -f javax/transaction/xa/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/naming/ldap/$(am__dirstamp) -rm -f java/awt/geom/$(am__dirstamp) - -rm -f javax/transaction/xa/$(am__dirstamp) - -rm -f gnu/java/nio/$(DEPDIR)/$(am__dirstamp) - -rm -f org/w3c/dom/ranges/$(am__dirstamp) - -rm -f javax/swing/plaf/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/registry/$(am__dirstamp) - -rm -f javax/swing/undo/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/registry/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/accessibility/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/security/provider/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/peer/$(am__dirstamp) - -rm -f java/nio/channels/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/imageio/spi/$(DEPDIR)/$(am__dirstamp) - -rm -f java/beans/$(am__dirstamp) - -rm -f gnu/java/lang/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/color/$(DEPDIR)/$(am__dirstamp) - -rm -f java/lang/reflect/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/io/$(DEPDIR)/$(am__dirstamp) - -rm -f java/security/interfaces/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/provider/$(am__dirstamp) + -rm -f javax/naming/event/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/font/$(am__dirstamp) + -rm -f java/text/$(am__dirstamp) -rm -f gnu/java/util/prefs/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/nio/channels/$(am__dirstamp) - -rm -f java/nio/charset/spi/$(DEPDIR)/$(am__dirstamp) - -rm -f java/lang/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/im/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/imageio/stream/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/image/$(am__dirstamp) - -rm -f java/security/spec/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/text/$(am__dirstamp) - -rm -f javax/imageio/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/$(am__dirstamp) - -rm -f javax/naming/directory/$(DEPDIR)/$(am__dirstamp) - -rm -f org/xml/sax/$(am__dirstamp) - -rm -f java/security/interfaces/$(am__dirstamp) - -rm -f javax/swing/colorchooser/$(am__dirstamp) - -rm -f java/awt/print/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/sql/$(DEPDIR)/$(am__dirstamp) - -rm -f java/util/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/$(am__dirstamp) - -rm -f org/xml/sax/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/awt/peer/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/dnd/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/beans/info/$(am__dirstamp) - -rm -f java/beans/beancontext/$(DEPDIR)/$(am__dirstamp) - -rm -f java/nio/charset/spi/$(am__dirstamp) - -rm -f javax/naming/spi/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/gcj/convert/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/plaf/$(am__dirstamp) - -rm -f java/nio/charset/$(am__dirstamp) - -rm -f javax/swing/text/$(DEPDIR)/$(am__dirstamp) - -rm -f java/util/prefs/$(DEPDIR)/$(am__dirstamp) - -rm -f java/security/cert/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/text/html/parser/$(DEPDIR)/$(am__dirstamp) - -rm -f java/security/acl/$(am__dirstamp) - -rm -f gnu/java/net/protocol/jar/$(am__dirstamp) - -rm -f java/text/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/attribute/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/rmic/$(am__dirstamp) + -rm -f javax/print/event/$(am__dirstamp) + -rm -f gnu/java/nio/charset/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/dgc/$(DEPDIR)/$(am__dirstamp) + -rm -f java/security/$(am__dirstamp) + -rm -f javax/swing/plaf/metal/$(am__dirstamp) + -rm -f gnu/gcj/convert/$(am__dirstamp) + -rm -f java/nio/channels/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/dgc/$(am__dirstamp) + -rm -f gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/math/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/util/$(DEPDIR)/$(am__dirstamp) -rm -f gnu/gcj/runtime/$(am__dirstamp) - -rm -f javax/swing/filechooser/$(am__dirstamp) - -rm -f gnu/java/security/der/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/regexp/$(am__dirstamp) + -rm -f java/nio/charset/$(am__dirstamp) + -rm -f jni/classpath/$(am__dirstamp) + -rm -f gnu/awt/$(am__dirstamp) -rm -f javax/security/auth/x500/$(am__dirstamp) - -rm -f org/w3c/dom/traversal/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/im/$(am__dirstamp) - -rm -f gnu/java/security/$(am__dirstamp) - -rm -f gnu/java/net/$(am__dirstamp) - -rm -f java/nio/charset/$(DEPDIR)/$(am__dirstamp) - -rm -f jni/gtk-peer/$(am__dirstamp) - -rm -f javax/swing/event/$(am__dirstamp) - -rm -f gnu/java/net/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/awt/peer/gtk/$(am__dirstamp) -rm -f java/awt/dnd/peer/$(DEPDIR)/$(am__dirstamp) -rm -f javax/swing/border/$(am__dirstamp) - -rm -f java/awt/geom/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/server/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/regexp/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/net/protocol/file/$(am__dirstamp) - -rm -f gnu/java/lang/reflect/$(am__dirstamp) + -rm -f gnu/java/nio/channels/$(DEPDIR)/$(am__dirstamp) + -rm -f jni/classpath/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/$(DEPDIR)/$(am__dirstamp) -rm -f java/net/$(am__dirstamp) - -rm -f gnu/java/lang/reflect/$(DEPDIR)/$(am__dirstamp) - -rm -f org/xml/sax/ext/$(am__dirstamp) - -rm -f gnu/java/awt/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/locale/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/transaction/$(am__dirstamp) - -rm -f java/rmi/registry/$(am__dirstamp) - -rm -f gnu/java/security/action/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/$(am__dirstamp) - -rm -f java/awt/print/$(am__dirstamp) - -rm -f java/text/$(am__dirstamp) - -rm -f java/util/logging/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/transaction/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/undo/$(am__dirstamp) - -rm -f gnu/java/security/util/$(am__dirstamp) - -rm -f java/nio/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/attribute/standard/$(DEPDIR)/$(am__dirstamp) - -rm -f org/w3c/dom/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/activation/$(am__dirstamp) - -rm -f java/rmi/activation/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/accessibility/$(am__dirstamp) - -rm -f gnu/java/nio/charset/$(am__dirstamp) - -rm -f java/security/$(DEPDIR)/$(am__dirstamp) - -rm -f java/util/jar/$(am__dirstamp) - -rm -f gnu/awt/j2d/$(am__dirstamp) - -rm -f javax/imageio/$(am__dirstamp) - -rm -f java/lang/$(am__dirstamp) - -rm -f org/w3c/dom/traversal/$(am__dirstamp) - -rm -f gnu/java/security/x509/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/awt/image/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/security/x509/$(am__dirstamp) - -rm -f java/beans/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/server/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/beans/editors/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/imageio/event/$(am__dirstamp) - -rm -f java/io/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/gcj/runtime/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/table/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/security/der/$(am__dirstamp) - -rm -f javax/imageio/event/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/rmi/registry/$(DEPDIR)/$(am__dirstamp) - -rm -f jni/classpath/$(am__dirstamp) - -rm -f javax/imageio/stream/$(am__dirstamp) - -rm -f gnu/java/net/protocol/http/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/colorchooser/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/classpath/$(am__dirstamp) - -rm -f gnu/java/nio/charset/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/tree/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/naming/ldap/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/nio/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/peer/$(am__dirstamp) + -rm -f java/awt/image/renderable/$(am__dirstamp) + -rm -f gnu/java/security/$(am__dirstamp) + -rm -f javax/naming/spi/$(DEPDIR)/$(am__dirstamp) + -rm -f java/nio/$(am__dirstamp) + -rm -f java/nio/charset/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/net/protocol/core/$(am__dirstamp) + -rm -f gnu/java/nio/$(am__dirstamp) + -rm -f java/lang/ref/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/dgc/$(am__dirstamp) + -rm -f java/awt/peer/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/color/$(DEPDIR)/$(am__dirstamp) + -rm -f java/util/zip/$(am__dirstamp) + -rm -f java/awt/datatransfer/$(DEPDIR)/$(am__dirstamp) -rm -f java/awt/image/renderable/$(DEPDIR)/$(am__dirstamp) - -rm -f java/beans/beancontext/$(am__dirstamp) - -rm -f gnu/java/beans/$(DEPDIR)/$(am__dirstamp) -rm -f java/util/zip/$(DEPDIR)/$(am__dirstamp) - -rm -f org/w3c/dom/ranges/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/peer/$(DEPDIR)/$(am__dirstamp) -rm -f javax/swing/plaf/basic/$(am__dirstamp) - -rm -f gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/awt/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/event/$(am__dirstamp) - -rm -f gnu/awt/xlib/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/swing/plaf/metal/$(am__dirstamp) - -rm -f java/util/logging/$(am__dirstamp) - -rm -f java/lang/reflect/$(am__dirstamp) - -rm -f gnu/java/security/provider/$(am__dirstamp) - -rm -f gnu/java/beans/info/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/sql/$(am__dirstamp) - -rm -f javax/naming/$(am__dirstamp) - -rm -f java/security/spec/$(am__dirstamp) - -rm -f java/awt/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/net/protocol/gcjlib/$(am__dirstamp) - -rm -f gnu/java/rmi/dgc/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/dgc/$(am__dirstamp) -rm -f gnu/gcj/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/event/$(DEPDIR)/$(am__dirstamp) - -rm -f java/sql/$(am__dirstamp) + -rm -f javax/swing/plaf/basic/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/awt/xlib/$(am__dirstamp) + -rm -f gnu/awt/j2d/$(am__dirstamp) -rm -f java/util/jar/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/math/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/beans/$(am__dirstamp) - -rm -f javax/naming/ldap/$(am__dirstamp) + -rm -f gnu/java/lang/reflect/$(am__dirstamp) + -rm -f javax/print/attribute/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/colorchooser/$(am__dirstamp) + -rm -f javax/print/attribute/$(am__dirstamp) + -rm -f javax/print/$(am__dirstamp) + -rm -f java/security/cert/$(am__dirstamp) + -rm -f gnu/awt/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/naming/directory/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/action/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/x509/$(DEPDIR)/$(am__dirstamp) + -rm -f org/w3c/dom/$(am__dirstamp) + -rm -f java/nio/channels/spi/$(am__dirstamp) + -rm -f gnu/java/lang/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/server/$(am__dirstamp) + -rm -f gnu/gcj/xlib/$(am__dirstamp) + -rm -f gnu/java/rmi/server/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/color/$(am__dirstamp) + -rm -f java/awt/print/$(DEPDIR)/$(am__dirstamp) + -rm -f java/lang/reflect/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/der/$(am__dirstamp) + -rm -f gnu/java/net/protocol/http/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/text/$(DEPDIR)/$(am__dirstamp) -rm -f java/util/prefs/$(am__dirstamp) + -rm -f gnu/java/security/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/print/$(am__dirstamp) + -rm -f java/awt/geom/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/imageio/event/$(am__dirstamp) + -rm -f javax/imageio/spi/$(am__dirstamp) + -rm -f gnu/gcj/io/$(am__dirstamp) + -rm -f gnu/java/nio/charset/$(am__dirstamp) + -rm -f javax/swing/plaf/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/naming/$(DEPDIR)/$(am__dirstamp) -rm -f gnu/java/net/protocol/gcjlib/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/color/$(am__dirstamp) - -rm -f javax/swing/border/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/gcj/io/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/lang/$(am__dirstamp) + -rm -f java/nio/channels/spi/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/im/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/transaction/xa/$(am__dirstamp) + -rm -f javax/swing/table/$(DEPDIR)/$(am__dirstamp) + -rm -f java/security/cert/$(DEPDIR)/$(am__dirstamp) + -rm -f java/beans/$(DEPDIR)/$(am__dirstamp) + -rm -f org/w3c/dom/traversal/$(am__dirstamp) + -rm -f javax/swing/$(am__dirstamp) + -rm -f java/rmi/registry/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/awt/image/$(am__dirstamp) + -rm -f javax/naming/directory/$(am__dirstamp) + -rm -f javax/swing/plaf/metal/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/lang/reflect/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/imageio/spi/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/print/event/$(DEPDIR)/$(am__dirstamp) + -rm -f java/nio/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/tree/$(am__dirstamp) + -rm -f gnu/java/rmi/dgc/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/image/$(DEPDIR)/$(am__dirstamp) -rm -f sysdep/$(DEPDIR)/$(am__dirstamp) - -rm -f java/applet/$(DEPDIR)/$(am__dirstamp) - -rm -f java/rmi/server/$(am__dirstamp) + -rm -f java/text/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/classpath/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/$(am__dirstamp) + -rm -f javax/imageio/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/awt/xlib/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/x509/$(am__dirstamp) + -rm -f gnu/java/awt/image/$(DEPDIR)/$(am__dirstamp) + -rm -f java/beans/beancontext/$(am__dirstamp) + -rm -f gnu/java/rmi/$(am__dirstamp) + -rm -f gnu/regexp/$(am__dirstamp) + -rm -f java/security/interfaces/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/net/protocol/http/$(am__dirstamp) + -rm -f jni/gtk-peer/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/awt/peer/gtk/$(am__dirstamp) + -rm -f javax/accessibility/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/imageio/event/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/accessibility/$(am__dirstamp) + -rm -f gnu/java/awt/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/regexp/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/util/$(am__dirstamp) + -rm -f javax/print/$(DEPDIR)/$(am__dirstamp) -rm -f gnu/java/rmi/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/naming/event/$(DEPDIR)/$(am__dirstamp) - -rm -f java/math/$(am__dirstamp) - -rm -f gnu/java/text/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/imageio/spi/$(am__dirstamp) - -rm -f gnu/gcj/xlib/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/naming/event/$(am__dirstamp) - -rm -f gnu/java/awt/$(am__dirstamp) - -rm -f java/awt/im/spi/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/net/protocol/core/$(am__dirstamp) - -rm -f gnu/java/io/$(am__dirstamp) + -rm -f java/awt/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/event/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/beans/editors/$(am__dirstamp) + -rm -f java/nio/charset/spi/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/text/$(am__dirstamp) + -rm -f gnu/classpath/$(am__dirstamp) + -rm -f java/math/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/net/$(am__dirstamp) + -rm -f javax/swing/text/$(am__dirstamp) + -rm -f javax/swing/table/$(am__dirstamp) + -rm -f gnu/java/beans/$(DEPDIR)/$(am__dirstamp) -rm -f javax/swing/text/html/$(am__dirstamp) - -rm -f org/xml/sax/ext/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/util/$(am__dirstamp) - -rm -f java/rmi/dgc/$(DEPDIR)/$(am__dirstamp) - -rm -f java/nio/channels/spi/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/nio/channels/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/awt/xlib/$(am__dirstamp) - -rm -f gnu/awt/j2d/$(DEPDIR)/$(am__dirstamp) - -rm -f javax/print/event/$(DEPDIR)/$(am__dirstamp) -rm -f java/io/$(am__dirstamp) - -rm -f org/xml/sax/helpers/$(DEPDIR)/$(am__dirstamp) - -rm -f org/w3c/dom/$(am__dirstamp) - -rm -f javax/print/attribute/$(am__dirstamp) + -rm -f gnu/gcj/$(am__dirstamp) + -rm -f java/util/jar/$(am__dirstamp) + -rm -f javax/print/attribute/standard/$(am__dirstamp) + -rm -f javax/security/auth/x500/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/naming/spi/$(am__dirstamp) + -rm -f javax/swing/filechooser/$(am__dirstamp) + -rm -f javax/swing/event/$(am__dirstamp) + -rm -f javax/sql/$(am__dirstamp) + -rm -f java/awt/image/$(am__dirstamp) + -rm -f gnu/java/beans/info/$(am__dirstamp) + -rm -f java/awt/event/$(am__dirstamp) + -rm -f gnu/java/net/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/registry/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/transaction/$(DEPDIR)/$(am__dirstamp) + -rm -f java/util/$(am__dirstamp) + -rm -f gnu/java/io/$(am__dirstamp) + -rm -f java/beans/beancontext/$(DEPDIR)/$(am__dirstamp) + -rm -f java/util/regex/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/beans/info/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/undo/$(am__dirstamp) + -rm -f java/awt/dnd/peer/$(am__dirstamp) + -rm -f javax/swing/undo/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/registry/$(am__dirstamp) + -rm -f sysdep/$(am__dirstamp) + -rm -f java/applet/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/text/html/parser/$(DEPDIR)/$(am__dirstamp) + -rm -f java/lang/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/imageio/$(am__dirstamp) + -rm -f java/sql/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/awt/peer/$(am__dirstamp) + -rm -f java/rmi/activation/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/text/html/parser/$(am__dirstamp) + -rm -f gnu/java/security/provider/$(DEPDIR)/$(am__dirstamp) + -rm -f java/security/spec/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/registry/$(am__dirstamp) + -rm -f gnu/java/awt/peer/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/security/der/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/sql/$(DEPDIR)/$(am__dirstamp) + -rm -f org/w3c/dom/ranges/$(DEPDIR)/$(am__dirstamp) + -rm -f java/security/acl/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/server/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/net/protocol/gcjlib/$(am__dirstamp) + -rm -f gnu/java/locale/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/datatransfer/$(am__dirstamp) + -rm -f gnu/java/util/prefs/$(am__dirstamp) + -rm -f java/security/spec/$(am__dirstamp) + -rm -f java/util/$(DEPDIR)/$(am__dirstamp) + -rm -f java/net/$(DEPDIR)/$(am__dirstamp) + -rm -f java/lang/ref/$(am__dirstamp) + -rm -f gnu/java/util/$(am__dirstamp) + -rm -f gnu/java/nio/channels/$(am__dirstamp) + -rm -f java/rmi/$(DEPDIR)/$(am__dirstamp) + -rm -f org/xml/sax/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/java/rmi/rmic/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/transaction/$(am__dirstamp) -rm -f gnu/java/math/$(am__dirstamp) - -rm -f java/math/$(DEPDIR)/$(am__dirstamp) + -rm -f java/util/regex/$(am__dirstamp) + -rm -f gnu/java/security/action/$(am__dirstamp) + -rm -f gnu/java/net/protocol/jar/$(DEPDIR)/$(am__dirstamp) + -rm -f java/nio/charset/spi/$(am__dirstamp) + -rm -f java/awt/im/$(am__dirstamp) + -rm -f javax/swing/text/html/$(DEPDIR)/$(am__dirstamp) -rm -f java/awt/im/spi/$(am__dirstamp) - -rm -f gnu/java/net/protocol/core/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/nio/$(am__dirstamp) - -rm -f java/awt/dnd/$(am__dirstamp) - -rm -f gnu/gcj/io/$(am__dirstamp) - -rm -f java/security/acl/$(DEPDIR)/$(am__dirstamp) - -rm -f java/awt/event/$(am__dirstamp) - -rm -f javax/naming/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/net/protocol/http/$(am__dirstamp) - -rm -f javax/swing/plaf/metal/$(DEPDIR)/$(am__dirstamp) + -rm -f java/io/$(DEPDIR)/$(am__dirstamp) -rm -f gnu/java/security/util/$(DEPDIR)/$(am__dirstamp) - -rm -f gnu/java/security/action/$(am__dirstamp) - -rm -f java/nio/$(am__dirstamp) + -rm -f java/awt/dnd/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/imageio/stream/$(am__dirstamp) + -rm -f org/w3c/dom/ranges/$(am__dirstamp) + -rm -f java/awt/dnd/$(am__dirstamp) + -rm -f gnu/java/beans/editors/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/font/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/plaf/$(am__dirstamp) + -rm -f java/util/logging/$(am__dirstamp) + -rm -f gnu/java/net/protocol/core/$(DEPDIR)/$(am__dirstamp) + -rm -f jni/gtk-peer/$(am__dirstamp) + -rm -f gnu/gcj/xlib/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/print/attribute/standard/$(DEPDIR)/$(am__dirstamp) + -rm -f java/rmi/server/$(am__dirstamp) + -rm -f gnu/awt/j2d/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/event/$(DEPDIR)/$(am__dirstamp) + -rm -f org/xml/sax/$(am__dirstamp) + -rm -f gnu/java/awt/peer/gtk/$(DEPDIR)/$(am__dirstamp) + -rm -f java/security/acl/$(am__dirstamp) + -rm -f gnu/java/io/$(DEPDIR)/$(am__dirstamp) + -rm -f org/xml/sax/ext/$(DEPDIR)/$(am__dirstamp) + -rm -f org/xml/sax/helpers/$(DEPDIR)/$(am__dirstamp) + -rm -f java/awt/im/spi/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/gcj/convert/$(DEPDIR)/$(am__dirstamp) + -rm -f java/lang/$(am__dirstamp) + -rm -f gnu/java/text/$(DEPDIR)/$(am__dirstamp) -rm -f java/nio/channels/$(am__dirstamp) - -rm -f java/security/$(am__dirstamp) - -rm -f jni/classpath/$(DEPDIR)/$(am__dirstamp) + -rm -f java/sql/$(am__dirstamp) + -rm -f javax/imageio/stream/$(DEPDIR)/$(am__dirstamp) + -rm -f gnu/gcj/io/$(DEPDIR)/$(am__dirstamp) + -rm -f javax/swing/filechooser/$(DEPDIR)/$(am__dirstamp) + -rm -f java/applet/$(am__dirstamp) + -rm -f javax/naming/event/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" diff --git a/libjava/gnu/awt/LightweightRedirector.java b/libjava/gnu/awt/LightweightRedirector.java index a0ea7bcff4b..41dc124279c 100644 --- a/libjava/gnu/awt/LightweightRedirector.java +++ b/libjava/gnu/awt/LightweightRedirector.java @@ -141,7 +141,7 @@ public class LightweightRedirector MouseEvent redirected = new MouseEvent(source, event.getID(), event.getWhen(), - event.getModifiers(), + event.getModifiersEx(), x, y, event.getClickCount(), event.isPopupTrigger()); @@ -157,20 +157,20 @@ public class LightweightRedirector */ int getButtonNumber(InputEvent event) { - int modifiers = event.getModifiers(); + int modifiers = event.getModifiersEx(); modifiers &= - InputEvent.BUTTON1_MASK | - InputEvent.BUTTON2_MASK | - InputEvent.BUTTON3_MASK; + InputEvent.BUTTON1_DOWN_MASK | + InputEvent.BUTTON2_DOWN_MASK | + InputEvent.BUTTON3_DOWN_MASK; switch (modifiers) { - case InputEvent.BUTTON1_MASK: + case InputEvent.BUTTON1_DOWN_MASK: return 1; - case InputEvent.BUTTON2_MASK: + case InputEvent.BUTTON2_DOWN_MASK: return 2; - case InputEvent.BUTTON3_MASK: + case InputEvent.BUTTON3_DOWN_MASK: return 3; case 0: return 0; diff --git a/libjava/gnu/awt/xlib/XEventLoop.java b/libjava/gnu/awt/xlib/XEventLoop.java index 5f5026b0cdb..66878185b51 100644 --- a/libjava/gnu/awt/xlib/XEventLoop.java +++ b/libjava/gnu/awt/xlib/XEventLoop.java @@ -197,13 +197,13 @@ public class XEventLoop implements Runnable switch (buttonEvt.button) { case 1: - modifiers = InputEvent.BUTTON1_MASK; + modifiers = InputEvent.BUTTON1_DOWN_MASK; break; case 2: - modifiers = InputEvent.BUTTON2_MASK; + modifiers = InputEvent.BUTTON2_DOWN_MASK; break; case 3: - modifiers = InputEvent.BUTTON2_MASK; + modifiers = InputEvent.BUTTON2_DOWN_MASK; break; } diff --git a/libjava/gnu/java/awt/peer/GLightweightPeer.java b/libjava/gnu/java/awt/peer/GLightweightPeer.java index dfd9e1e26e9..643c40f2ad4 100644 --- a/libjava/gnu/java/awt/peer/GLightweightPeer.java +++ b/libjava/gnu/java/awt/peer/GLightweightPeer.java @@ -1,5 +1,5 @@ /* GLightweightPeer.java -- - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,7 +45,6 @@ import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Font; -import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GraphicsConfiguration; diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java index 8ea6817f33e..c374ba21826 100644 --- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java +++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics.java @@ -64,7 +64,7 @@ public class GdkGraphics extends Graphics static final int GDK_COPY = 0, GDK_XOR = 2; - native int[] initState (GtkComponentPeer component); + native void initState (GtkComponentPeer component); native void initState (int width, int height); native void copyState (GdkGraphics g); @@ -84,15 +84,15 @@ public class GdkGraphics extends Graphics initState (width, height); color = Color.black; clip = new Rectangle (0, 0, width, height); - font = new Font ("Dialog", Font.PLAIN, 10); + font = new Font ("Dialog", Font.PLAIN, 12); } GdkGraphics (GtkComponentPeer component) { this.component = component; - int rgb[] = initState (component); - color = new Color (rgb[0], rgb[1], rgb[2]); - font = component.awtComponent.getFont(); + initState (component); + color = component.awtComponent.getForeground (); + font = component.awtComponent.getFont (); Dimension d = component.awtComponent.getSize (); clip = new Rectangle (0, 0, d.width, d.height); } @@ -126,6 +126,11 @@ public class GdkGraphics extends Graphics native public void dispose (); native void copyPixmap (Graphics g, int x, int y, int width, int height); + native void copyAndScalePixmap (Graphics g, boolean flip_x, boolean flip_y, + int src_x, int src_y, + int src_width, int src_height, + int dest_x, int dest_y, + int dest_width, int dest_height); public boolean drawImage (Image img, int x, int y, Color bgcolor, ImageObserver observer) { @@ -161,7 +166,10 @@ public class GdkGraphics extends Graphics { if (img instanceof GtkOffScreenImage) { - throw new RuntimeException (); + copyAndScalePixmap (img.getGraphics (), false, false, + 0, 0, img.getWidth (null), img.getHeight (null), + x, y, width, height); + return true; } GtkImage image = (GtkImage) img; @@ -186,7 +194,60 @@ public class GdkGraphics extends Graphics { if (img instanceof GtkOffScreenImage) { - throw new RuntimeException (); + int dx_start, dy_start, d_width, d_height; + int sx_start, sy_start, s_width, s_height; + boolean x_flip = false; + boolean y_flip = false; + + if (dx1 < dx2) + { + dx_start = dx1; + d_width = dx2 - dx1; + } + else + { + dx_start = dx2; + d_width = dx1 - dx2; + x_flip ^= true; + } + if (dy1 < dy2) + { + dy_start = dy1; + d_height = dy2 - dy1; + } + else + { + dy_start = dy2; + d_height = dy1 - dy2; + y_flip ^= true; + } + if (sx1 < sx2) + { + sx_start = sx1; + s_width = sx2 - sx1; + } + else + { + sx_start = sx2; + s_width = sx1 - sx2; + x_flip ^= true; + } + if (sy1 < sy2) + { + sy_start = sy1; + s_height = sy2 - sy1; + } + else + { + sy_start = sy2; + s_height = sy1 - sy2; + y_flip ^= true; + } + + copyAndScalePixmap (img.getGraphics (), x_flip, y_flip, + sx_start, sy_start, s_width, s_height, + dx_start, dy_start, d_width, d_height); + return true; } GtkImage image = (GtkImage) img; @@ -238,13 +299,48 @@ public class GdkGraphics extends Graphics public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - // System.out.println ("drawRoundRect called [UNIMPLEMENTED]"); + if (arcWidth > width) + arcWidth = width; + if (arcHeight > height) + arcHeight = height; + + int xx = x + width - arcWidth; + int yy = y + height - arcHeight; + + drawArc (x, y, arcWidth, arcHeight, 90, 90); + drawArc (xx, y, arcWidth, arcHeight, 0, 90); + drawArc (xx, yy, arcWidth, arcHeight, 270, 90); + drawArc (x, yy, arcWidth, arcHeight, 180, 90); + + int y1 = y + arcHeight / 2; + int y2 = y + height - arcHeight / 2; + drawLine (x, y1, x, y2); + drawLine (x + width, y1, x + width, y2); + + int x1 = x + arcWidth / 2; + int x2 = x + width - arcWidth / 2; + drawLine (x1, y, x2, y); + drawLine (x1, y + height, x2, y + height); } public void fillRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight) { - // System.out.println ("fillRoundRect called [UNIMPLEMENTED]"); + if (arcWidth > width) + arcWidth = width; + if (arcHeight > height) + arcHeight = height; + + int xx = x + width - arcWidth; + int yy = y + height - arcHeight; + + fillArc (x, y, arcWidth, arcHeight, 90, 90); + fillArc (xx, y, arcWidth, arcHeight, 0, 90); + fillArc (xx, yy, arcWidth, arcHeight, 270, 90); + fillArc (x, yy, arcWidth, arcHeight, 180, 90); + + fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1); + fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height); } public Shape getClip () diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java index ebff68ef987..0986960b8b3 100644 --- a/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java +++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphics2D.java @@ -1,5 +1,5 @@ /* GdkGraphics2D.java - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -48,7 +48,6 @@ import java.util.HashMap; import java.util.Map; import java.text.AttributedCharacterIterator; -import java.util.Map; import java.util.Stack; import java.lang.Integer; import gnu.java.awt.ClasspathToolkit; @@ -88,7 +87,7 @@ public class GdkGraphics2D extends Graphics2D private Stack stateStack; - native private int[] initState (GtkComponentPeer component); + native private void initState (GtkComponentPeer component); native private void initState (int width, int height); native private void copyState (GdkGraphics2D g); native public void dispose (); @@ -169,10 +168,10 @@ public class GdkGraphics2D extends Graphics2D GdkGraphics2D (GtkComponentPeer component) { this.component = component; - int rgb[] = initState (component); + initState (component); - setColor (new Color (rgb[0], rgb[1], rgb[2])); - setBackground (new Color (rgb[3], rgb[4], rgb[5])); + setColor (component.awtComponent.getForeground ()); + setBackground (component.awtComponent.getBackground ()); setPaint (getColor()); setFont (new Font("SansSerif", Font.PLAIN, 12)); setTransform (new AffineTransform ()); @@ -1478,14 +1477,28 @@ public class GdkGraphics2D extends Graphics2D public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - int x1 = x + arcWidth, x2 = x + width - arcWidth; - int y1 = y + arcHeight, y2 = y + height - arcHeight; - fillRect (x1, y, x2 - x1, height); - fillRect (x, y1, width, y2 - y1); - fillArc (x, y, arcWidth, arcHeight, 90, 90); - fillArc (x1, y, arcWidth, arcHeight, 0, 90); - fillArc (x2, y2, arcWidth, arcHeight, 270, 90); - fillArc (x, y2, arcWidth, arcHeight, 180, 90); + if (arcWidth > width) + arcWidth = width; + if (arcHeight > height) + arcHeight = height; + + int xx = x + width - arcWidth; + int yy = y + height - arcHeight; + + drawArc (x, y, arcWidth, arcHeight, 90, 90); + drawArc (xx, y, arcWidth, arcHeight, 0, 90); + drawArc (xx, yy, arcWidth, arcHeight, 270, 90); + drawArc (x, yy, arcWidth, arcHeight, 180, 90); + + int y1 = y + arcHeight / 2; + int y2 = y + height - arcHeight / 2; + drawLine (x, y1, x, y2); + drawLine (x + width, y1, x + width, y2); + + int x1 = x + arcWidth / 2; + int x2 = x + width - arcWidth / 2; + drawLine (x1, y, x2, y); + drawLine (x1, y + height, x2, y + height); } public void drawString (String str, int x, int y) @@ -1527,14 +1540,21 @@ public class GdkGraphics2D extends Graphics2D public void fillRoundRect (int x, int y, int width, int height, int arcWidth, int arcHeight) { - int x1 = x + arcWidth, x2 = x + width - arcWidth; - int y1 = y + arcHeight, y2 = y + height - arcHeight; - fillRect (x1, y, x2 - x1, height); - fillRect (x, y1, width, y2 - y1); + if (arcWidth > width) + arcWidth = width; + if (arcHeight > height) + arcHeight = height; + + int xx = x + width - arcWidth; + int yy = y + height - arcHeight; + fillArc (x, y, arcWidth, arcHeight, 90, 90); - fillArc (x1, y, arcWidth, arcHeight, 0, 90); - fillArc (x2, y2, arcWidth, arcHeight, 270, 90); - fillArc (x, y2, arcWidth, arcHeight, 180, 90); + fillArc (xx, y, arcWidth, arcHeight, 0, 90); + fillArc (xx, yy, arcWidth, arcHeight, 270, 90); + fillArc (x, yy, arcWidth, arcHeight, 180, 90); + + fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1); + fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height); } public Font getFont () diff --git a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java index cdd5f9ca907..db8aed6087b 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkButtonPeer.java @@ -50,12 +50,13 @@ import java.awt.peer.ButtonPeer; public class GtkButtonPeer extends GtkComponentPeer implements ButtonPeer { - native void create (); + native void create (String label); + public native void connectJObject (); public native void connectSignals (); native void gtkSetFont (String name, int style, int size); - native void gtkSetLabel(String label); + native void gtkSetLabel (String label); native void gtkWidgetSetForeground (int red, int green, int blue); native void gtkActivate (); @@ -64,6 +65,11 @@ public class GtkButtonPeer extends GtkComponentPeer super (b); } + void create () + { + create (((Button) awtComponent).getLabel ()); + } + public void setLabel (String label) { gtkSetLabel(label); @@ -78,10 +84,10 @@ public class GtkButtonPeer extends GtkComponentPeer p.translate(((Component) me.getSource()).getX(), ((Component) me.getSource()).getY()); if (!me.isConsumed () - && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0 + && (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0 && awtComponent.getBounds().contains(p)) postActionEvent (((Button)awtComponent).getActionCommand (), - me.getModifiers ()); + me.getModifiersEx ()); } if (e.getID () == KeyEvent.KEY_PRESSED) @@ -90,18 +96,11 @@ public class GtkButtonPeer extends GtkComponentPeer if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE) { postActionEvent (((Button) awtComponent).getActionCommand (), - ke.getModifiers ()); + ke.getModifiersEx ()); gtkActivate (); } } super.handleEvent (e); } - - public void getArgs (Component component, GtkArgList args) - { - super.getArgs (component, args); - - args.add ("label", ((Button)component).getLabel ()); - } } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java index a4657988184..361136f08e9 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java @@ -52,39 +52,39 @@ public class GtkCheckboxPeer extends GtkComponentPeer // The current state of the GTK checkbox. private boolean currentState; - public native void nativeCreate (GtkCheckboxGroupPeer group, - boolean state); + public native void create (GtkCheckboxGroupPeer group); public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group); public native void connectSignals (); native void gtkSetFont (String name, int style, int size); - public native void gtkSetLabel (String label); + native void gtkButtonSetLabel (String label); + native void gtkToggleButtonSetActive (boolean is_active); public GtkCheckboxPeer (Checkbox c) { super (c); } - // We can't fully use the ordinary getArgs code here, due to - // oddities of this particular widget. In particular we must be - // able to switch between a checkbutton and a radiobutton - // dynamically. + // FIXME: we must be able to switch between a checkbutton and a + // radiobutton dynamically. public void create () { - CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup (); + Checkbox checkbox = (Checkbox) awtComponent; + CheckboxGroup g = checkbox.getCheckboxGroup (); old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g); - currentState = ((Checkbox)awtComponent).getState(); - nativeCreate (old_group, currentState); + create (old_group); + gtkToggleButtonSetActive (checkbox.getState ()); + gtkButtonSetLabel (checkbox.getLabel ()); } public void setState (boolean state) { if (currentState != state) - set ("active", state); + gtkToggleButtonSetActive (state); } public void setLabel (String label) { - gtkSetLabel (label); + gtkButtonSetLabel (label); } public void setCheckboxGroup (CheckboxGroup group) @@ -100,13 +100,6 @@ public class GtkCheckboxPeer extends GtkComponentPeer } } - public void getArgs (Component component, GtkArgList args) - { - super.getArgs (component, args); - args.add ("active", ((Checkbox) component).getState ()); - args.add ("label", ((Checkbox) component).getLabel ()); - } - // Override the superclass postItemEvent so that the peer doesn't // need information that we have. public void postItemEvent (Object item, int stateChange) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java index a03a410508c..2ecea5cb9ba 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkChoicePeer.java @@ -58,25 +58,22 @@ public class GtkChoicePeer extends GtkComponentPeer items[i] = c.getItem (i); append (items); - - // Must set our state before notifying listeners - ((Choice) awtComponent).select (c.getItem (0)); - postItemEvent (c.getItem (0), ItemEvent.SELECTED); } } native void create (); native void append (String items[]); - native int getHistory (); + native int nativeGetSelected (); native void nativeAdd (String item, int index); native void nativeRemove (int index); + native void nativeRemoveAll (); native public void select (int position); public void add (String item, int index) { - int before = getHistory(); + int before = nativeGetSelected(); nativeAdd (item, index); @@ -92,11 +89,11 @@ public class GtkChoicePeer extends GtkComponentPeer public void remove (int index) { - int before = getHistory(); + int before = nativeGetSelected(); int after; nativeRemove (index); - after = getHistory(); + after = nativeGetSelected(); /* Generate an ItemEvent if we are removing the currently selected item and there are at least one item left. */ @@ -110,7 +107,7 @@ public class GtkChoicePeer extends GtkComponentPeer public void removeAll () { - nativeRemove (-1); + nativeRemoveAll(); } public void addItem (String item, int position) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java index 15e73d9c3f7..eae5a948bc4 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -61,7 +61,6 @@ import java.awt.Toolkit; import java.awt.Window; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; -import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.PaintEvent; @@ -93,6 +92,8 @@ public class GtkComponentPeer extends GtkGenericPeer native void gtkWidgetSetCursor (int type); native void gtkWidgetSetBackground (int red, int green, int blue); native void gtkWidgetSetForeground (int red, int green, int blue); + native void gtkWidgetSetSensitive (boolean sensitive); + native void gtkWidgetSetParent (ComponentPeer parent); native void gtkWidgetRequestFocus (); native void gtkWidgetDispatchKeyEvent (int id, long when, int mods, int keyCode, int keyLocation); @@ -115,37 +116,59 @@ public class GtkComponentPeer extends GtkGenericPeer this.awtComponent = awtComponent; insets = new Insets (0, 0, 0, 0); - create (); - - GtkArgList args = new GtkArgList (); - getArgs (awtComponent, args); - args.setArgs (this); - - connectJObject (); - connectSignals (); - - if (awtComponent.getForeground () != null) - setForeground (awtComponent.getForeground ()); - if (awtComponent.getBackground () != null) - setBackground (awtComponent.getBackground ()); - if (awtComponent.getFont() != null) - setFont(awtComponent.getFont()); - - setCursor (awtComponent.getCursor ()); - if (this instanceof GtkFileDialogPeer && awtComponent.getHeight() == 0 - && awtComponent.getWidth() == 0) + create (); + + setParent (); + + connectJObject (); + connectSignals (); + + if (awtComponent.getForeground () != null) + setForeground (awtComponent.getForeground ()); + if (awtComponent.getBackground () != null) + setBackground (awtComponent.getBackground ()); + if (awtComponent.getFont() != null) + setFont(awtComponent.getFont()); + + setCursor (awtComponent.getCursor ()); + + setComponentBounds (); + + Rectangle bounds = awtComponent.getBounds (); + setBounds (bounds.x, bounds.y, bounds.width, bounds.height); + setVisibleAndEnabled (); + } + + void setParent () + { + ComponentPeer p; + Component component = awtComponent; + do { - int[] dims = new int[2]; - gtkWidgetGetDimensions(dims); - ((GtkFileDialogPeer) this).setBoundsCallback((Window)awtComponent, - awtComponent.getX(), - awtComponent.getY(), - dims[0], dims[1]); + component = component.getParent (); + p = component.getPeer (); } + while (p instanceof java.awt.peer.LightweightPeer); + + if (p != null) + gtkWidgetSetParent (p); + } + + /* + * Set the bounds of this peer's AWT Component based on dimensions + * returned by the native windowing system. Most Components impose + * their dimensions on the peers so the default implementation does + * nothing. However some peers, like GtkFileDialogPeer, need to + * pass their size back to the AWT Component. + */ + void setComponentBounds () + { + } - Rectangle bounds = awtComponent.getBounds (); - setBounds (bounds.x, bounds.y, bounds.width, bounds.height); + void setVisibleAndEnabled () + { setVisible (awtComponent.isVisible ()); + setEnabled (awtComponent.isEnabled ()); } public int checkImage (Image image, int width, int height, @@ -260,12 +283,12 @@ public class GtkComponentPeer extends GtkGenericPeer break; case KeyEvent.KEY_PRESSED: ke = (KeyEvent) event; - gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (), + gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiersEx (), ke.getKeyCode (), ke.getKeyLocation ()); break; case KeyEvent.KEY_RELEASED: ke = (KeyEvent) event; - gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (), + gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiersEx (), ke.getKeyCode (), ke.getKeyLocation ()); break; } @@ -417,7 +440,7 @@ public class GtkComponentPeer extends GtkGenericPeer public void setEnabled (boolean b) { - set ("sensitive", b); + gtkWidgetSetSensitive (b); } public void setFont (Font f) @@ -506,45 +529,6 @@ public class GtkComponentPeer extends GtkGenericPeer item, stateChange)); } - public void getArgs (Component component, GtkArgList args) - { - args.add ("sensitive", component.isEnabled ()); - - ComponentPeer p; - - do - { - component = component.getParent (); - p = component.getPeer (); - } while (p instanceof java.awt.peer.LightweightPeer); - - if (p != null) - args.add ("parent", p); - } - - native void set (String name, String value); - native void set (String name, boolean value); - native void set (String name, int value); - native void set (String name, float value); - native void set (String name, Object value); - - void set (GtkArg arg) - { - String name = arg.getName (); - Object value = arg.getValue (); - - if (value instanceof Boolean) - set (name, ((Boolean)value).booleanValue ()); - else if (value instanceof Integer) - set (name, ((Integer)value).intValue ()); - else if (value instanceof Float) - set (name, ((Float)value).floatValue ()); - else if (value instanceof String) - set (name, ((String) value)); - else - set (name, value); - } - public GraphicsConfiguration getGraphicsConfiguration () { // FIXME: just a stub for now. diff --git a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java index 4febbef9c9a..1d6ce8b8bf0 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java @@ -85,17 +85,11 @@ public class GtkDialogPeer extends GtkWindowPeer { // Create a decorated dialog window. create (GDK_WINDOW_TYPE_HINT_DIALOG, true); - } - - public void getArgs (Component component, GtkArgList args) - { - super.getArgs (component, args); - Dialog dialog = (Dialog) component; + Dialog dialog = (Dialog) awtComponent; - args.add ("title", dialog.getTitle ()); - args.add ("modal", dialog.isModal ()); - args.add ("allow_shrink", dialog.isResizable ()); - args.add ("allow_grow", dialog.isResizable ()); + gtkWindowSetModal (dialog.isModal ()); + setTitle (dialog.getTitle ()); + setResizable (dialog.isResizable ()); } } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java index 712247c4a85..d31e0c5be02 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java @@ -42,6 +42,7 @@ import java.awt.AWTEvent; import java.awt.Dialog; import java.awt.FileDialog; import java.awt.Graphics; +import java.awt.Window; import java.awt.event.WindowEvent; import java.awt.peer.FileDialogPeer; import java.io.FilenameFilter; @@ -81,6 +82,20 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer super (fd); } + void setComponentBounds () + { + if (awtComponent.getHeight () == 0 + && awtComponent.getWidth () == 0) + { + int[] dims = new int[2]; + gtkWidgetGetPreferredDimensions (dims); + ((GtkFileDialogPeer) this).setBoundsCallback ((Window) awtComponent, + awtComponent.getX (), + awtComponent.getY (), + dims[0], dims[1]); + } + } + public void setFile (String fileName) { /* If nothing changed do nothing. This usually happens because diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java index c542b63ad31..e1a877eedcb 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -47,6 +47,7 @@ import java.awt.MenuBar; import java.awt.Rectangle; import java.awt.Window; import java.awt.event.PaintEvent; +import java.awt.image.ColorModel; import java.awt.peer.FramePeer; import java.awt.peer.MenuBarPeer; @@ -115,10 +116,9 @@ public class GtkFramePeer extends GtkWindowPeer setSize (awtComponent.getWidth() - insets.left - insets.right, awtComponent.getHeight() - insets.top - insets.bottom + menuBarHeight); - set ("allow_shrink", resizable); - set ("allow_grow", resizable); - } - + gtkWindowSetResizable (resizable); + } + protected void postInsetsChangedEvent (int top, int left, int bottom, int right) { @@ -137,24 +137,46 @@ public class GtkFramePeer extends GtkWindowPeer { // Create a normal decorated window. create (GDK_WINDOW_TYPE_HINT_NORMAL, true); - setMenuBar(((Frame) awtComponent).getMenuBar()); - awtComponent.setForeground(java.awt.SystemColor.windowText); - } - public void getArgs (Component component, GtkArgList args) - { - super.getArgs (component, args); + Frame frame = (Frame) awtComponent; - Frame frame = (Frame) component; + setMenuBar (frame.getMenuBar ()); - args.add ("title", frame.getTitle ()); - args.add ("allow_shrink", frame.isResizable ()); - args.add ("allow_grow", frame.isResizable ()); + setTitle (frame.getTitle ()); + setResizable (frame.isResizable ()); + setIconImage(frame.getIconImage()); } + native void nativeSetIconImageFromDecoder (GdkPixbufDecoder decoder); + native void nativeSetIconImageFromData (int[] pixels, int width, int height); public void setIconImage (Image image) { - /* TODO: Waiting on Toolkit Image routines */ + if (image != null) + { + GtkImage img = (GtkImage) image; + // FIXME: Image should be loaded, but if not, do image loading here. + if (img.isLoaded()) + { + if (img.getSource() instanceof GdkPixbufDecoder) + { + nativeSetIconImageFromDecoder((GdkPixbufDecoder) img.getSource()); + } + else + { + int[] pixels = img.getPixelCache(); + ColorModel model = img.getColorModel(); + int[] data = new int[pixels.length * 4]; + for (int i = 0; i < pixels.length; i++) + { + data[i * 4] = model.getRed(pixels[i]); + data[i * 4 + 1] = model.getGreen(pixels[i]); + data[i * 4 + 2] = model.getBlue(pixels[i]); + data[i * 4 + 3] = model.getAlpha(pixels[i]); + } + nativeSetIconImageFromData(data, img.getWidth(null), img.getHeight(null)); + } + } + } } public Graphics getGraphics () diff --git a/libjava/gnu/java/awt/peer/gtk/GtkImage.java b/libjava/gnu/java/awt/peer/gtk/GtkImage.java index 27d3d6a0655..9234d248aba 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkImage.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkImage.java @@ -89,6 +89,18 @@ public class GtkImage extends Image implements ImageConsumer this.observer = observer; } + public synchronized int[] + getPixelCache () + { + return pixelCache; + } + + public synchronized ColorModel + getColorModel () + { + return model; + } + public synchronized int getWidth (ImageObserver observer) { diff --git a/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java index 9ca30c92fa9..a85aba952fd 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkListPeer.java @@ -144,7 +144,7 @@ public class GtkListPeer extends GtkComponentPeer // multiple click. MouseEvent me = (MouseEvent) e; if (!me.isConsumed () - && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0 + && (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0 && me.getClickCount() == 2) { String selectedItem = ((List) awtComponent).getSelectedItem (); @@ -153,7 +153,7 @@ public class GtkListPeer extends GtkComponentPeer // something is selected. if (selectedItem != null) postActionEvent (((List) awtComponent).getSelectedItem (), - me.getModifiers ()); + me.getModifiersEx ()); } } @@ -167,7 +167,7 @@ public class GtkListPeer extends GtkComponentPeer // Enter only generates an Action event if something is // selected. if (selectedItem != null) - postActionEvent (selectedItem, ke.getModifiers ()); + postActionEvent (selectedItem, ke.getModifiersEx ()); } } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java b/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java index 6efa8410197..4cbe190731c 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkMainThread.java @@ -43,7 +43,18 @@ public class GtkMainThread extends GtkGenericPeer implements Runnable private static Thread mainThread = null; private static Object mainThreadLock = new Object(); - static native void gtkInit(); + // Whether the gtk+ subsystem has been initialized. + private boolean gtkInitCalled = false; + + /** + * Call gtk_init. It is very important that this happen before any other + * gtk calls. + * + * @param portableNativeSync 1 if the Java property + * gnu.classpath.awt.gtk.portable.native.sync is set to "true". 0 if it is + * set to "false". -1 if unset. + */ + static native void gtkInit(int portableNativeSync); native void gtkMain(); public GtkMainThread() @@ -59,18 +70,38 @@ public class GtkMainThread extends GtkGenericPeer implements Runnable synchronized (this) { mainThread.start(); - try { - wait(); - } catch (InterruptedException e) { } + + while (!gtkInitCalled) + { + try + { + wait(); + } + catch (InterruptedException e) { } + } } } public void run() { + /* Pass the value of the gnu.classpath.awt.gtk.portable.native.sync system + * property to C. */ + int portableNativeSync; + String portNatSyncProp = + System.getProperty("gnu.classpath.awt.gtk.portable.native.sync"); + + if (portNatSyncProp == null) + portableNativeSync = -1; // unset + else if (Boolean.valueOf(portNatSyncProp).booleanValue()) + portableNativeSync = 1; // true + else + portableNativeSync = 0; // false + synchronized (this) { - gtkInit(); - notify(); + gtkInit(portableNativeSync); + gtkInitCalled = true; + notifyAll(); } gtkMain(); } diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java index 40462818081..b9cca1a5c38 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java @@ -56,15 +56,12 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer create (); } + native void nativeSetHelpMenu(MenuPeer menuPeer); + /* In Gnome, help menus are no longer right flushed. */ public void addHelpMenu (Menu menu) { - addMenu (menu); - } - - public void addMenu (Menu menu) - { - addMenu ((MenuPeer) menu.getPeer ()); + nativeSetHelpMenu((MenuPeer) menu.getPeer()); } native public void delMenu (int index); diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java index 55581d1c64e..c32839ec6ba 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java @@ -89,10 +89,8 @@ public class GtkMenuItemPeer extends GtkMenuComponentPeer setEnabled (true); } - public void setEnabled (boolean b) - { - // do nothing, for now. - } + native public void setEnabled (boolean b); + native public void setLabel (String label); protected void postMenuActionEvent () diff --git a/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java index 9b3f678856e..dc170b1cf12 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkMenuPeer.java @@ -52,11 +52,15 @@ public class GtkMenuPeer extends GtkMenuItemPeer native void create (String label); native void addItem (MenuItemPeer item, int key, boolean shiftModifier); native void setupAccelGroup (GtkGenericPeer container); + native void addTearOff (); public GtkMenuPeer (Menu menu) { super (menu); + if (menu.isTearOff()) + addTearOff(); + MenuContainer parent = menu.getParent (); if (parent instanceof Menu) setupAccelGroup ((GtkGenericPeer)((Menu)parent).getPeer ()); diff --git a/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java b/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java index 22086c5a08c..786c4b44936 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkOffScreenImage.java @@ -76,7 +76,10 @@ public class GtkOffScreenImage extends Image public Graphics getGraphics () { - return g; + if (g instanceof GdkGraphics2D) + return new GdkGraphics2D ((GdkGraphics2D) this.g); + else + return new GdkGraphics ((GdkGraphics) this.g); } public Object getProperty (String name, ImageObserver observer) diff --git a/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java index 111c1f96979..d4a702deb35 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java @@ -50,6 +50,8 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer implements TextFieldPeer { native void create (int width); + native void gtkWidgetSetBackground (int red, int green, int blue); + native void gtkWidgetSetForeground (int red, int green, int blue); void create () { @@ -76,6 +78,8 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer int text_width = cols * fm.getMaxAdvance (); create (text_width); + + setEditable (tf.isEditable ()); } native int gtkEntryGetBorderWidth (); @@ -162,7 +166,7 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_ENTER) - postActionEvent (getText (), ke.getModifiers ()); + postActionEvent (getText (), ke.getModifiersEx ()); } super.handleEvent (e); diff --git a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java index 7e77e0dcbf0..a2357699b3c 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -60,6 +60,10 @@ public class GtkWindowPeer extends GtkContainerPeer private boolean hasBeenShown = false; private int oldState = Frame.NORMAL; + native void gtkWindowSetTitle (String title); + native void gtkWindowSetResizable (boolean resizable); + native void gtkWindowSetModal (boolean modal); + native void create (int type, boolean decorated, int width, int height, GtkWindowPeer parent, @@ -92,6 +96,16 @@ public class GtkWindowPeer extends GtkContainerPeer create (GDK_WINDOW_TYPE_HINT_NORMAL, false); } + void setParent () + { + setVisible (awtComponent.isVisible ()); + setEnabled (awtComponent.isEnabled ()); + } + + void setVisibleAndEnabled () + { + } + native void connectJObject (); native void connectSignals (); @@ -100,12 +114,6 @@ public class GtkWindowPeer extends GtkContainerPeer super (window); } - public void getArgs (Component component, GtkArgList args) - { - args.add ("visible", component.isVisible ()); - args.add ("sensitive", component.isEnabled ()); - } - native public void toBack (); native public void toFront (); @@ -120,7 +128,7 @@ public class GtkWindowPeer extends GtkContainerPeer public void setTitle (String title) { - set ("title", title); + gtkWindowSetTitle (title); } native void setSize (int width, int height); @@ -132,8 +140,7 @@ public class GtkWindowPeer extends GtkContainerPeer // was resizable. setSize (awtComponent.getWidth() - insets.left - insets.right, awtComponent.getHeight() - insets.top - insets.bottom); - set ("allow_shrink", resizable); - set ("allow_grow", resizable); + gtkWindowSetResizable (resizable); } native void setBoundsCallback (Window window, diff --git a/libjava/java/awt/AWTKeyStroke.java b/libjava/java/awt/AWTKeyStroke.java index 9848d43ef63..23ae92bf098 100644 --- a/libjava/java/awt/AWTKeyStroke.java +++ b/libjava/java/awt/AWTKeyStroke.java @@ -409,13 +409,13 @@ public class AWTKeyStroke implements Serializable { token = t.nextToken(); if ("shift".equals(token)) - modifiers |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK; + modifiers |= KeyEvent.SHIFT_DOWN_MASK; else if ("ctrl".equals(token) || "control".equals(token)) - modifiers |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK; + modifiers |= KeyEvent.CTRL_DOWN_MASK; else if ("meta".equals(token)) - modifiers |= KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK; + modifiers |= KeyEvent.META_DOWN_MASK; else if ("alt".equals(token)) - modifiers |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK; + modifiers |= KeyEvent.ALT_DOWN_MASK; else if ("button1".equals(token)) modifiers |= KeyEvent.BUTTON1_DOWN_MASK; else if ("button2".equals(token)) diff --git a/libjava/java/awt/Button.java b/libjava/java/awt/Button.java index 54b201ed1c4..0bb5766dbf0 100644 --- a/libjava/java/awt/Button.java +++ b/libjava/java/awt/Button.java @@ -101,7 +101,7 @@ private transient ActionListener action_listeners; public Button() { - this(null); + this(""); } /*************************************************************************/ diff --git a/libjava/java/awt/Color.java b/libjava/java/awt/Color.java index c41117a6e33..c32438521be 100644 --- a/libjava/java/awt/Color.java +++ b/libjava/java/awt/Color.java @@ -506,7 +506,7 @@ public class Color implements Paint, Serializable /** * Returns the RGB value for this color, in the sRGB color space. The blue - * value will be in bits 0-7, green in 8-15, red in 6-23, and alpha value in + * value will be in bits 0-7, green in 8-15, red in 16-23, and alpha value in * 24-31. * * @return the RGB value for this color @@ -772,9 +772,9 @@ public class Color implements Paint, Serializable if (red == max) array[0] = (green - blue) / delta; else if (green == max) - array[0] = 1 / 3 + (blue - red) / delta; + array[0] = 1f / 3 + (blue - red) / delta; else - array[0] = 2 / 3 + (red - green) / delta; + array[0] = 2f / 3 + (red - green) / delta; if (array[0] < 0) array[0]++; } diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index 5cb792b1de4..90aaaf91f52 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -58,6 +58,7 @@ import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelEvent; import java.awt.event.PaintEvent; +import java.awt.event.WindowEvent; import java.awt.im.InputContext; import java.awt.im.InputMethodRequests; import java.awt.image.BufferStrategy; @@ -2262,7 +2263,7 @@ public abstract class Component * This method simply calls handleEvent and returns the result. * * @param e the event to handle - * @return the result of handling e + * @return true if the event was handled, false otherwise * @deprecated use {@link #dispatchEvent(AWTEvent)} instead */ public boolean postEvent(Event e) @@ -3028,6 +3029,7 @@ public abstract class Component mouseListener.mouseReleased(e); break; } + e.consume(); } /** @@ -3055,6 +3057,7 @@ public abstract class Component mouseMotionListener.mouseMoved(e); break; } + e.consume(); } /** @@ -3073,7 +3076,10 @@ public abstract class Component { if (mouseWheelListener != null && e.id == MouseEvent.MOUSE_WHEEL) + { mouseWheelListener.mouseWheelMoved(e); + e.consume(); + } } /** @@ -3205,135 +3211,145 @@ public abstract class Component } /** - * AWT 1.0 mouse event handler. + * AWT 1.0 MOUSE_DOWN event handler. This method is meant to be + * overridden by components providing their own MOUSE_DOWN handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseEvent(MouseEvent)} instead */ public boolean mouseDown(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 MOUSE_DRAG event handler. This method is meant to be + * overridden by components providing their own MOUSE_DRAG handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead */ public boolean mouseDrag(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 MOUSE_UP event handler. This method is meant to be + * overridden by components providing their own MOUSE_UP handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseEvent(MouseEvent)} instead */ public boolean mouseUp(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 MOUSE_MOVE event handler. This method is meant to be + * overridden by components providing their own MOUSE_MOVE handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead */ public boolean mouseMove(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 MOUSE_ENTER event handler. This method is meant to be + * overridden by components providing their own MOUSE_ENTER handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseEvent(MouseEvent)} instead */ public boolean mouseEnter(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 mouse event. + * AWT 1.0 MOUSE_EXIT event handler. This method is meant to be + * overridden by components providing their own MOUSE_EXIT handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param x the x coordinate, ignored * @param y the y coordinate, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processMouseEvent(MouseEvent)} instead */ public boolean mouseExit(Event evt, int x, int y) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 key press event. + * AWT 1.0 KEY_PRESS and KEY_ACTION event handler. This method is + * meant to be overridden by components providing their own key + * press handler. The default implementation simply returns false. * * @param evt the event to handle * @param key the key pressed, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processKeyEvent(KeyEvent)} instead */ public boolean keyDown(Event evt, int key) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 key press event. + * AWT 1.0 KEY_RELEASE and KEY_ACTION_RELEASE event handler. This + * method is meant to be overridden by components providing their + * own key release handler. The default implementation simply + * returns false. * * @param evt the event to handle * @param key the key pressed, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processKeyEvent(KeyEvent)} instead */ public boolean keyUp(Event evt, int key) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 action event processor. + * AWT 1.0 ACTION_EVENT event handler. This method is meant to be + * overridden by components providing their own action event + * handler. The default implementation simply returns false. * * @param evt the event to handle * @param what the object acted on, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated in classes which support actions, use * processActionEvent(ActionEvent) instead */ public boolean action(Event evt, Object what) { - // XXX Add backward compatibility handling. return false; } @@ -3377,30 +3393,32 @@ public abstract class Component } /** - * AWT 1.0 focus event. + * AWT 1.0 GOT_FOCUS event handler. This method is meant to be + * overridden by components providing their own GOT_FOCUS handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param what the Object focused, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processFocusEvent(FocusEvent)} instead */ public boolean gotFocus(Event evt, Object what) { - // XXX Add backward compatibility handling. return false; } /** - * AWT 1.0 focus event. + * AWT 1.0 LOST_FOCUS event handler. This method is meant to be + * overridden by components providing their own LOST_FOCUS handler. + * The default implementation simply returns false. * * @param evt the event to handle * @param what the Object focused, ignored - * @return false: since the method was deprecated, the return has no meaning + * @return false * @deprecated use {@link #processFocusEvent(FocusEvent)} instead */ public boolean lostFocus(Event evt, Object what) { - // XXX Add backward compatibility handling. return false; } @@ -3415,7 +3433,7 @@ public abstract class Component */ public boolean isFocusTraversable() { - return enabled && visible && (peer == null || peer.isFocusTraversable()); + return enabled && visible && (peer == null || isLightweight() || peer.isFocusTraversable()); } /** @@ -3430,7 +3448,11 @@ public abstract class Component } /** - * Specify whether this component can receive focus. + * Specify whether this component can receive focus. This method also + * sets the {@link #isFocusTraversableOverridden} field to 1, which + * appears to be the undocumented way {@link + * DefaultFocusTraversalPolicy#accept()} determines whether to respect + * the {@link #isFocusable()} method of the component. * * @param focusable the new focusable status * @since 1.4 @@ -3439,6 +3461,7 @@ public abstract class Component { firePropertyChange("focusable", this.focusable, focusable); this.focusable = focusable; + this.isFocusTraversableOverridden = 1; } /** @@ -3697,7 +3720,7 @@ public abstract class Component Window toplevel = (Window) parent; if (toplevel.isFocusableWindow ()) { - if (peer != null) + if (peer != null && !isLightweight()) // 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. @@ -3783,7 +3806,7 @@ public abstract class Component Window toplevel = (Window) parent; if (toplevel.isFocusableWindow ()) { - if (peer != null) + if (peer != null && !isLightweight()) // 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. @@ -3904,6 +3927,7 @@ public abstract class Component if (focusedWindow == toplevel) { if (peer != null + && !isLightweight() && !(this instanceof Window)) // This call will cause a FOCUS_GAINED event to be // posted to the system event queue if the native @@ -4495,23 +4519,23 @@ p *
  • the set of backward traversal keys int id = e.getID (); int oldMods = 0; - int mods = ie.getModifiers (); + int mods = ie.getModifiersEx (); - if ((mods & InputEvent.BUTTON2_MASK) != 0) + if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0) oldMods |= Event.META_MASK; - else if ((mods & InputEvent.BUTTON3_MASK) != 0) + else if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0) oldMods |= Event.ALT_MASK; - if ((mods & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0) + if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0) oldMods |= Event.SHIFT_MASK; - if ((mods & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) + if ((mods & InputEvent.CTRL_DOWN_MASK) != 0) oldMods |= Event.CTRL_MASK; - if ((mods & (InputEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0) + if ((mods & InputEvent.META_DOWN_MASK) != 0) oldMods |= Event.META_MASK; - if ((mods & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0) + if ((mods & InputEvent.ALT_DOWN_MASK) != 0) oldMods |= Event.ALT_MASK; if (e instanceof MouseEvent) @@ -4673,7 +4697,8 @@ p *
  • the set of backward traversal keys * * @param e the event to dispatch */ - void dispatchEventImpl(AWTEvent e) + + void dispatchEventImpl (AWTEvent e) { Event oldEvent = translateEvent (e); @@ -4681,7 +4706,30 @@ p *
  • the set of backward traversal keys postEvent (oldEvent); if (eventTypeEnabled (e.id)) - processEvent(e); + { + // the trick we use to communicate between dispatch and redispatch + // is to have KeyboardFocusManager.redispatch synchronize on the + // object itself. we then do not redispatch to KeyboardFocusManager + // if we are already holding the lock. + if (! Thread.holdsLock(e)) + { + switch (e.id) + { + case WindowEvent.WINDOW_GAINED_FOCUS: + case WindowEvent.WINDOW_LOST_FOCUS: + case KeyEvent.KEY_PRESSED: + case KeyEvent.KEY_RELEASED: + case KeyEvent.KEY_TYPED: + case FocusEvent.FOCUS_GAINED: + case FocusEvent.FOCUS_LOST: + if (KeyboardFocusManager + .getCurrentKeyboardFocusManager() + .dispatchEvent(e)) + return; + } + } + processEvent (e); + } } /** diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java index 6c70e940e8e..e0ad22c4750 100644 --- a/libjava/java/awt/Container.java +++ b/libjava/java/awt/Container.java @@ -1505,10 +1505,11 @@ public class Container extends Component void dispatchEventImpl(AWTEvent e) { // Give lightweight dispatcher a chance to handle it. - if (dispatcher != null + if (eventTypeEnabled (e.id) + && dispatcher != null && dispatcher.handleEvent (e)) return; - + if ((e.id <= ContainerEvent.CONTAINER_LAST && e.id >= ContainerEvent.CONTAINER_FIRST) && (containerListener != null @@ -1586,7 +1587,6 @@ public class Container extends Component { if (dispatcher == null) dispatcher = new LightweightDispatcher (this); - dispatcher.enableEvents (component[i].eventMask); } @@ -1831,7 +1831,6 @@ class LightweightDispatcher implements Serializable { private static final long serialVersionUID = 5184291520170872969L; private Container nativeContainer; - private Component focus; private Cursor nativeCursor; private long eventMask; @@ -1845,11 +1844,6 @@ class LightweightDispatcher implements Serializable nativeContainer = c; } - void enableEvents(long l) - { - eventMask |= l; - } - void acquireComponentForMouseEvent(MouseEvent me) { int x = me.getX (); @@ -1863,8 +1857,9 @@ class LightweightDispatcher implements Serializable { candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y); - if (candidate == null) + if (candidate == null || (candidate.eventMask & me.getID()) == 0) { + candidate = null; p = SwingUtilities.convertPoint(parent, p.x, p.y, parent.parent); parent = parent.parent; } @@ -1881,21 +1876,25 @@ class LightweightDispatcher implements Serializable && lastComponentEntered.isShowing() && lastComponentEntered != candidate) { - Point tp = - SwingUtilities.convertPoint(nativeContainer, - x, y, lastComponentEntered); - MouseEvent exited = new MouseEvent (lastComponentEntered, - MouseEvent.MOUSE_EXITED, - me.getWhen (), - me.getModifiers (), - tp.x, tp.y, - me.getClickCount (), - me.isPopupTrigger (), - me.getButton ()); - lastComponentEntered.dispatchEvent (exited); + // Old candidate could have been removed from + // the nativeContainer so we check first. + if (SwingUtilities.isDescendingFrom(lastComponentEntered, nativeContainer)) + { + Point tp = + SwingUtilities.convertPoint(nativeContainer, + x, y, lastComponentEntered); + MouseEvent exited = new MouseEvent (lastComponentEntered, + MouseEvent.MOUSE_EXITED, + me.getWhen (), + me.getModifiersEx (), + tp.x, tp.y, + me.getClickCount (), + me.isPopupTrigger (), + me.getButton ()); + lastComponentEntered.dispatchEvent (exited); + } lastComponentEntered = null; } - // If we have a candidate, maybe enter it. if (candidate != null) { @@ -1911,7 +1910,7 @@ class LightweightDispatcher implements Serializable MouseEvent entered = new MouseEvent (lastComponentEntered, MouseEvent.MOUSE_ENTERED, me.getWhen (), - me.getModifiers (), + me.getModifiersEx (), cp.x, cp.y, me.getClickCount (), me.isPopupTrigger (), @@ -1929,7 +1928,8 @@ class LightweightDispatcher implements Serializable // - MOUSE_RELEASED // - MOUSE_PRESSED: another button pressed while the first is held down // - MOUSE_DRAGGED - mouseEventTarget = pressedComponent; + if (SwingUtilities.isDescendingFrom(pressedComponent, nativeContainer)) + mouseEventTarget = pressedComponent; else if (me.getID() == MouseEvent.MOUSE_CLICKED) { // Don't dispatch CLICKED events whose target is not the same as the @@ -1943,9 +1943,6 @@ class LightweightDispatcher implements Serializable boolean handleEvent(AWTEvent e) { - if ((eventMask & e.getID()) == 0) - return false; - if (e instanceof MouseEvent) { MouseEvent me = (MouseEvent) e; @@ -1979,12 +1976,10 @@ class LightweightDispatcher implements Serializable pressedComponent = null; break; } + if (newEvt.isConsumed()) + e.consume(); } } - else if (e instanceof KeyEvent && focus != null) - { - focus.processKeyEvent((KeyEvent) e); - } return e.isConsumed(); } diff --git a/libjava/java/awt/DefaultFocusTraversalPolicy.java b/libjava/java/awt/DefaultFocusTraversalPolicy.java index 73b1e95a9a4..f49f386a19c 100644 --- a/libjava/java/awt/DefaultFocusTraversalPolicy.java +++ b/libjava/java/awt/DefaultFocusTraversalPolicy.java @@ -92,19 +92,17 @@ public class DefaultFocusTraversalPolicy && comp.enabled) { if (comp.isFocusTraversableOverridden != 0 - && comp.isFocusTraversable ()) - return true; - else - { - if (!(comp instanceof Canvas - || comp instanceof Panel - || comp instanceof Label - || comp instanceof ScrollPane - || comp instanceof Scrollbar - || comp instanceof Window - || comp.isLightweight ())) - return true; - } + && (comp.isFocusTraversable () || comp.isFocusable())) + return true; + + if (!(comp instanceof Canvas + || comp instanceof Panel + || comp instanceof Label + || comp instanceof ScrollPane + || comp instanceof Scrollbar + || comp instanceof Window + || comp.isLightweight ())) + return true; } return false; } diff --git a/libjava/java/awt/DefaultKeyboardFocusManager.java b/libjava/java/awt/DefaultKeyboardFocusManager.java index d4c8bdd4fa8..7912e29f056 100644 --- a/libjava/java/awt/DefaultKeyboardFocusManager.java +++ b/libjava/java/awt/DefaultKeyboardFocusManager.java @@ -155,7 +155,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager && e.id != WindowEvent.WINDOW_DEACTIVATED) return false; - target.dispatchEvent (e); + redispatchEvent(target, e); return true; } else if (e instanceof FocusEvent) @@ -197,7 +197,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager setGlobalPermanentFocusOwner (null); } - target.dispatchEvent (e); + redispatchEvent(target, e); return true; } @@ -258,7 +258,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager Component focusOwner = getGlobalPermanentFocusOwner (); if (focusOwner != null) - focusOwner.dispatchEvent (e); + redispatchEvent(focusOwner, e); // Loop through all registered KeyEventPostProcessors, giving // each a chance to process this event. @@ -284,10 +284,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { // Check if this event represents a menu shortcut. - // MenuShortcuts are activated by Ctrl- KeyEvents. - int modifiers = e.getModifiers (); - if ((modifiers & KeyEvent.CTRL_MASK) != 0 - || (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0) + // MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED. + int modifiers = e.getModifiersEx (); + if (e.getID() == KeyEvent.KEY_PRESSED + && (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0) { Window focusedWindow = getGlobalFocusedWindow (); if (focusedWindow instanceof Frame) @@ -311,17 +311,21 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager MenuItem item = menu.getItem (j); MenuShortcut shortcut = item.getShortcut (); - if (shortcut != null) + if (item.isEnabled() && shortcut != null) { - // Dispatch a new ActionEvent if this is a - // Shift- KeyEvent and the shortcut requires - // the Shift modifier, or if the shortcut - // doesn't require the Shift modifier. - if ((shortcut.usesShiftModifier () - && ((modifiers & KeyEvent.SHIFT_MASK) != 0 - || (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0) - || !shortcut.usesShiftModifier ()) - && shortcut.getKey () == e.getKeyCode ()) + // Dispatch a new ActionEvent if: + // + // a) this is a Shift- KeyEvent, and the + // shortcut requires the Shift modifier + // + // or, b) this is not a Shift- KeyEvent, and the + // shortcut does not require the Shift + // modifier. + if (shortcut.getKey () == e.getKeyCode () + && ((shortcut.usesShiftModifier () + && (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0) + || (! shortcut.usesShiftModifier () + && (modifiers & KeyEvent.SHIFT_DOWN_MASK) == 0))) { item.dispatchEvent (new ActionEvent (item, ActionEvent.ACTION_PERFORMED, @@ -347,7 +351,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager // KEY_PRESSED TAB is a focus traversal keystroke, we also need to // consume KEY_RELEASED and KEY_TYPED TAB key events). AWTKeyStroke oppositeKeystroke = AWTKeyStroke.getAWTKeyStroke (e.getKeyCode (), - e.getModifiers (), + e.getModifiersEx (), !(e.id == KeyEvent.KEY_RELEASED)); Set forwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); @@ -439,7 +443,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy (); Component previous = policy.getComponentBefore (focusCycleRoot, focusComp); - previous.requestFocusInWindow (); + if (previous != null) + previous.requestFocusInWindow (); } public void focusNextComponent (Component comp) @@ -449,7 +454,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy (); Component next = policy.getComponentAfter (focusCycleRoot, focusComp); - next.requestFocusInWindow (); + if (next != null) + next.requestFocusInWindow (); } public void upFocusCycle (Component comp) @@ -461,7 +467,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy (); Component defaultComponent = policy.getDefaultComponent (focusCycleRoot); - defaultComponent.requestFocusInWindow (); + if (defaultComponent != null) + defaultComponent.requestFocusInWindow (); } else { @@ -481,7 +488,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { FocusTraversalPolicy policy = cont.getFocusTraversalPolicy (); Component defaultComponent = policy.getDefaultComponent (cont); - defaultComponent.requestFocusInWindow (); + if (defaultComponent != null) + defaultComponent.requestFocusInWindow (); setGlobalCurrentFocusCycleRoot (cont); } } diff --git a/libjava/java/awt/Font.java b/libjava/java/awt/Font.java index 6a3514758b7..754e078d748 100644 --- a/libjava/java/awt/Font.java +++ b/libjava/java/awt/Font.java @@ -1265,12 +1265,28 @@ equals(Object obj) public String toString() { - return(getClass().getName() - + "(logical=" + getName () - + ",family=" + getFamily () - + ",name=" + getFontName () - + ",style=" + getStyle () - + ",size=" + getSize ()); + String styleString = ""; + + switch (getStyle ()) + { + case 0: + styleString = "plain"; + break; + case 1: + styleString = "bold"; + break; + case 2: + styleString = "italic"; + break; + default: + styleString = "unknown"; + } + + return getClass ().getName () + + "[family=" + getFamily () + + ",name=" + getFontName () + + ",style=" + styleString + + ",size=" + getSize () + "]"; } diff --git a/libjava/java/awt/Graphics.java b/libjava/java/awt/Graphics.java index d2207ead1c3..c75d34e4bc1 100644 --- a/libjava/java/awt/Graphics.java +++ b/libjava/java/awt/Graphics.java @@ -732,14 +732,14 @@ finalize() /*************************************************************************/ /** - * Returns a string representation of this object. - * - * @param A string representation of this object. - */ + * Returns a string representation of this object. + * + * @param A string representation of this object. + */ public String toString() { - return(super.toString()); + return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]"; } public boolean diff --git a/libjava/java/awt/KeyboardFocusManager.java b/libjava/java/awt/KeyboardFocusManager.java index e82c0d48825..3ae4dd6ca85 100644 --- a/libjava/java/awt/KeyboardFocusManager.java +++ b/libjava/java/awt/KeyboardFocusManager.java @@ -740,8 +740,11 @@ public abstract class KeyboardFocusManager public final void redispatchEvent (Component target, AWTEvent e) { - e.setSource (target); - dispatchEvent (e); + synchronized (e) + { + e.setSource (target); + target.dispatchEvent (e); + } } public abstract boolean dispatchKeyEvent (KeyEvent e); diff --git a/libjava/java/awt/MenuBar.java b/libjava/java/awt/MenuBar.java index fb267290008..1c9b1c78946 100644 --- a/libjava/java/awt/MenuBar.java +++ b/libjava/java/awt/MenuBar.java @@ -128,15 +128,15 @@ setHelpMenu(Menu menu) helpMenu.removeNotify (); helpMenu.parent = null; } + helpMenu = menu; - if (menu.parent != null) - menu.parent.remove (menu); if (menu.parent != null) menu.parent.remove (menu); menu.parent = this; if (peer != null) { + menu.addNotify(); MenuBarPeer mp = (MenuBarPeer) peer; mp.addHelpMenu (menu); } @@ -163,8 +163,7 @@ add(Menu menu) if (peer != null) { - MenuBarPeer mp = (MenuBarPeer) peer; - mp.addMenu (menu); + menu.addNotify(); } return(menu); @@ -269,6 +268,11 @@ addNotify() Menu mi = (Menu)e.nextElement(); mi.addNotify(); } + if (helpMenu != null) + { + helpMenu.addNotify(); + ((MenuBarPeer) peer).addHelpMenu(helpMenu); + } } /*************************************************************************/ diff --git a/libjava/java/awt/MenuItem.java b/libjava/java/awt/MenuItem.java index 8511f698fad..81a4a79bcfa 100644 --- a/libjava/java/awt/MenuItem.java +++ b/libjava/java/awt/MenuItem.java @@ -77,7 +77,7 @@ private String actionCommand; /** * @serial Indicates whether or not this menu item is enabled. */ -private boolean enabled; +private boolean enabled = true; /** * @serial The mask of events that are enabled for this menu item. diff --git a/libjava/java/awt/Rectangle.java b/libjava/java/awt/Rectangle.java index c3340bb8eb4..5dc54116fd2 100644 --- a/libjava/java/awt/Rectangle.java +++ b/libjava/java/awt/Rectangle.java @@ -542,7 +542,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable */ public boolean intersects(Rectangle r) { - return width > 0 && height > 0 && r.width > 0 && r.height > 0 + return r.width > 0 && r.height > 0 && width > 0 && height > 0 && r.x < x + width && r.x + r.width > x && r.y < y + height && r.y + r.height > y; } diff --git a/libjava/java/awt/geom/CubicCurve2D.java b/libjava/java/awt/geom/CubicCurve2D.java index 096e7ad9772..56b90e99838 100644 --- a/libjava/java/awt/geom/CubicCurve2D.java +++ b/libjava/java/awt/geom/CubicCurve2D.java @@ -1,5 +1,5 @@ /* CubicCurve2D.java -- represents a parameterized cubic curve in 2-D space - Copyright (C) 2002, 2003 Free Software Foundation + Copyright (C) 2002, 2003, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -35,7 +35,6 @@ 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.geom; import java.awt.Rectangle; @@ -53,12 +52,14 @@ import java.util.NoSuchElementException; * @author Eric Blake (ebb9@email.byu.edu) * @author Graydon Hoare (graydon@redhat.com) * @author Sascha Brawer (brawer@dandelis.ch) + * @author Sven de Marothy (sven@physto.se) * * @since 1.2 */ -public abstract class CubicCurve2D - implements Shape, Cloneable +public abstract class CubicCurve2D implements Shape, Cloneable { + private static final double BIG_VALUE = java.lang.Double.MAX_VALUE / 10.0; + /** * Constructs a new CubicCurve2D. Typical users will want to * construct instances of a subclass, such as {@link @@ -68,87 +69,74 @@ public abstract class CubicCurve2D { } - /** * Returns the x coordinate of the curve’s start * point. */ public abstract double getX1(); - /** * Returns the y coordinate of the curve’s start * point. */ public abstract double getY1(); - /** * Returns the curve’s start point. */ public abstract Point2D getP1(); - /** * Returns the x coordinate of the curve’s first * control point. */ public abstract double getCtrlX1(); - /** * Returns the y coordinate of the curve’s first * control point. */ public abstract double getCtrlY1(); - /** * Returns the curve’s first control point. */ public abstract Point2D getCtrlP1(); - /** * Returns the x coordinate of the curve’s second * control point. */ public abstract double getCtrlX2(); - /** * Returns the y coordinate of the curve’s second * control point. */ public abstract double getCtrlY2(); - /** * Returns the curve’s second control point. */ public abstract Point2D getCtrlP2(); - /** * Returns the x coordinate of the curve’s end * point. */ public abstract double getX2(); - /** * Returns the y coordinate of the curve’s end * point. */ public abstract double getY2(); - /** * Returns the curve’s end point. */ public abstract Point2D getP2(); - /** * Changes the curve geometry, separately specifying each coordinate * value. @@ -183,7 +171,6 @@ public abstract class CubicCurve2D public abstract void setCurve(double x1, double y1, double cx1, double cy1, double cx2, double cy2, double x2, double y2); - /** * Changes the curve geometry, specifying coordinate values in an * array. @@ -206,13 +193,11 @@ public abstract class CubicCurve2D */ public void setCurve(double[] coords, int offset) { - setCurve(coords[offset++], coords[offset++], - coords[offset++], coords[offset++], - coords[offset++], coords[offset++], + setCurve(coords[offset++], coords[offset++], coords[offset++], + coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++]); } - /** * Changes the curve geometry, specifying coordinate values in * separate Point objects. @@ -232,11 +217,10 @@ public abstract class CubicCurve2D */ public void setCurve(Point2D p1, Point2D c1, Point2D c2, Point2D p2) { - setCurve(p1.getX(), p1.getY(), c1.getX(), c1.getY(), - c2.getX(), c2.getY(), p2.getX(), p2.getY()); + setCurve(p1.getX(), p1.getY(), c1.getX(), c1.getY(), c2.getX(), c2.getY(), + p2.getX(), p2.getY()); } - /** * Changes the curve geometry, specifying coordinate values in an * array of Point objects. @@ -258,12 +242,10 @@ public abstract class CubicCurve2D */ public void setCurve(Point2D[] pts, int offset) { - setCurve(pts[offset].getX(), pts[offset++].getY(), - pts[offset].getX(), pts[offset++].getY(), - pts[offset].getX(), pts[offset++].getY(), + setCurve(pts[offset].getX(), pts[offset++].getY(), pts[offset].getX(), + pts[offset++].getY(), pts[offset].getX(), pts[offset++].getY(), pts[offset].getX(), pts[offset++].getY()); } - /** * Changes the curve geometry to that of another curve. @@ -276,7 +258,6 @@ public abstract class CubicCurve2D c.getCtrlX2(), c.getCtrlY2(), c.getX2(), c.getY2()); } - /** * Calculates the squared flatness of a cubic curve, directly * specifying each coordinate value. The flatness is the maximal @@ -309,7 +290,6 @@ public abstract class CubicCurve2D Line2D.ptSegDistSq(x1, y1, x2, y2, cx2, cy2)); } - /** * Calculates the flatness of a cubic curve, directly specifying * each coordinate value. The flatness is the maximal distance of a @@ -340,7 +320,6 @@ public abstract class CubicCurve2D return Math.sqrt(getFlatnessSq(x1, y1, cx1, cy1, cx2, cy2, x2, y2)); } - /** * Calculates the squared flatness of a cubic curve, specifying the * coordinate values in an array. The flatness is the maximal @@ -374,13 +353,11 @@ public abstract class CubicCurve2D */ public static double getFlatnessSq(double[] coords, int offset) { - return getFlatnessSq(coords[offset++], coords[offset++], - coords[offset++], coords[offset++], - coords[offset++], coords[offset++], + return getFlatnessSq(coords[offset++], coords[offset++], coords[offset++], + coords[offset++], coords[offset++], coords[offset++], coords[offset++], coords[offset++]); } - /** * Calculates the flatness of a cubic curve, specifying the * coordinate values in an array. The flatness is the maximal @@ -420,7 +397,6 @@ public abstract class CubicCurve2D coords[offset++], coords[offset++])); } - /** * Calculates the squared flatness of this curve. The flatness is * the maximal distance of a control point to the line between start @@ -441,7 +417,6 @@ public abstract class CubicCurve2D getCtrlX2(), getCtrlY2(), getX2(), getY2()); } - /** * Calculates the flatness of this curve. The flatness is the * maximal distance of a control point to the line between start and @@ -458,12 +433,10 @@ public abstract class CubicCurve2D */ public double getFlatness() { - return Math.sqrt(getFlatnessSq(getX1(), getY1(), getCtrlX1(), - getCtrlY1(), getCtrlX2(), getCtrlY2(), - getX2(), getY2())); + return Math.sqrt(getFlatnessSq(getX1(), getY1(), getCtrlX1(), getCtrlY1(), + getCtrlX2(), getCtrlY2(), getX2(), getY2())); } - /** * Subdivides this curve into two halves. * @@ -482,9 +455,11 @@ public abstract class CubicCurve2D public void subdivide(CubicCurve2D left, CubicCurve2D right) { // Use empty slots at end to share single array. - double[] d = new double[] { getX1(), getY1(), getCtrlX1(), getCtrlY1(), - getCtrlX2(), getCtrlY2(), getX2(), getY2(), - 0, 0, 0, 0, 0, 0 }; + double[] d = new double[] + { + getX1(), getY1(), getCtrlX1(), getCtrlY1(), getCtrlX2(), + getCtrlY2(), getX2(), getY2(), 0, 0, 0, 0, 0, 0 + }; subdivide(d, 0, d, 0, d, 6); if (left != null) left.setCurve(d, 0); @@ -492,7 +467,6 @@ public abstract class CubicCurve2D right.setCurve(d, 6); } - /** * Subdivides a cubic curve into two halves. * @@ -510,13 +484,12 @@ public abstract class CubicCurve2D * of src, or null if the caller is not * interested in the right half. */ - public static void subdivide(CubicCurve2D src, - CubicCurve2D left, CubicCurve2D right) + public static void subdivide(CubicCurve2D src, CubicCurve2D left, + CubicCurve2D right) { src.subdivide(left, right); } - /** * Subdivides a cubic curve into two halves, passing all coordinates * in an array. @@ -563,18 +536,29 @@ public abstract class CubicCurve2D * index where the start point’s x coordinate will be * stored. */ - public static void subdivide(double[] src, int srcOff, - double[] left, int leftOff, - double[] right, int rightOff) + public static void subdivide(double[] src, int srcOff, double[] left, + int leftOff, double[] right, int rightOff) { // To understand this code, please have a look at the image // "CubicCurve2D-3.png" in the sub-directory "doc-files". - double src_C1_x, src_C1_y, src_C2_x, src_C2_y; - double left_P1_x, left_P1_y; - double left_C1_x, left_C1_y, left_C2_x, left_C2_y; - double right_C1_x, right_C1_y, right_C2_x, right_C2_y; - double right_P2_x, right_P2_y; - double Mid_x, Mid_y; // Mid = left.P2 = right.P1 + double src_C1_x; + double src_C1_y; + double src_C2_x; + double src_C2_y; + double left_P1_x; + double left_P1_y; + double left_C1_x; + double left_C1_y; + double left_C2_x; + double left_C2_y; + double right_C1_x; + double right_C1_y; + double right_C2_x; + double right_C2_y; + double right_P2_x; + double right_P2_y; + double Mid_x; // Mid = left.P2 = right.P1 + double Mid_y; // Mid = left.P2 = right.P1 left_P1_x = src[srcOff]; left_P1_y = src[srcOff + 1]; @@ -599,31 +583,30 @@ public abstract class CubicCurve2D Mid_y = (left_C2_y + right_C1_y) / 2; if (left != null) - { - left[leftOff] = left_P1_x; - left[leftOff + 1] = left_P1_y; - left[leftOff + 2] = left_C1_x; - left[leftOff + 3] = left_C1_y; - left[leftOff + 4] = left_C2_x; - left[leftOff + 5] = left_C2_y; - left[leftOff + 6] = Mid_x; - left[leftOff + 7] = Mid_y; - } + { + left[leftOff] = left_P1_x; + left[leftOff + 1] = left_P1_y; + left[leftOff + 2] = left_C1_x; + left[leftOff + 3] = left_C1_y; + left[leftOff + 4] = left_C2_x; + left[leftOff + 5] = left_C2_y; + left[leftOff + 6] = Mid_x; + left[leftOff + 7] = Mid_y; + } if (right != null) - { - right[rightOff] = Mid_x; - right[rightOff + 1] = Mid_y; - right[rightOff + 2] = right_C1_x; - right[rightOff + 3] = right_C1_y; - right[rightOff + 4] = right_C2_x; - right[rightOff + 5] = right_C2_y; - right[rightOff + 6] = right_P2_x; - right[rightOff + 7] = right_P2_y; - } + { + right[rightOff] = Mid_x; + right[rightOff + 1] = Mid_y; + right[rightOff + 2] = right_C1_x; + right[rightOff + 3] = right_C1_y; + right[rightOff + 4] = right_C2_x; + right[rightOff + 5] = right_C2_y; + right[rightOff + 6] = right_P2_x; + right[rightOff + 7] = right_P2_y; + } } - /** * Finds the non-complex roots of a cubic equation, placing the * results into the same array as the equation coefficients. The @@ -670,7 +653,6 @@ public abstract class CubicCurve2D return solveCubic(eqn, eqn); } - /** * Finds the non-complex roots of a cubic equation. The following * equation is being solved: @@ -727,9 +709,19 @@ public abstract class CubicCurve2D // The Java implementation is very similar to the GSL code, but // not a strict one-to-one copy. For example, GSL would sort the // result. - - double a, b, c, q, r, Q, R; - double c3, Q3, R2, CR2, CQ3; + + double a; + double b; + double c; + double q; + double r; + double Q; + double R; + double c3; + double Q3; + double R2; + double CR2; + double CQ3; // If the cubic coefficient is zero, we have a quadratic equation. c3 = eqn[3]; @@ -755,219 +747,267 @@ public abstract class CubicCurve2D CQ3 = 2916 * q * q * q; if (R == 0 && Q == 0) - { - // The GNU Scientific Library would return three identical - // solutions in this case. - res[0] = -a/3; - return 1; - } - - if (CR2 == CQ3) - { - /* this test is actually R2 == Q3, written in a form suitable - for exact computation with integers */ - - /* Due to finite precision some double roots may be missed, and - considered to be a pair of complex roots z = x +/- epsilon i - close to the real axis. */ - - double sqrtQ = Math.sqrt(Q); - - if (R > 0) { - res[0] = -2 * sqrtQ - a/3; - res[1] = sqrtQ - a/3; + // The GNU Scientific Library would return three identical + // solutions in this case. + res[0] = -a / 3; + return 1; } - else + + if (CR2 == CQ3) { - res[0] = -sqrtQ - a/3; - res[1] = 2 * sqrtQ - a/3; + /* this test is actually R2 == Q3, written in a form suitable + for exact computation with integers */ + /* Due to finite precision some double roots may be missed, and + considered to be a pair of complex roots z = x +/- epsilon i + close to the real axis. */ + double sqrtQ = Math.sqrt(Q); + + if (R > 0) + { + res[0] = -2 * sqrtQ - a / 3; + res[1] = sqrtQ - a / 3; + } + else + { + res[0] = -sqrtQ - a / 3; + res[1] = 2 * sqrtQ - a / 3; + } + return 2; } - return 2; - } if (CR2 < CQ3) /* equivalent to R2 < Q3 */ - { - double sqrtQ = Math.sqrt(Q); - double sqrtQ3 = sqrtQ * sqrtQ * sqrtQ; - double theta = Math.acos(R / sqrtQ3); - double norm = -2 * sqrtQ; - res[0] = norm * Math.cos(theta / 3) - a / 3; - res[1] = norm * Math.cos((theta + 2.0 * Math.PI) / 3) - a/3; - res[2] = norm * Math.cos((theta - 2.0 * Math.PI) / 3) - a/3; - - // The GNU Scientific Library sorts the results. We don't. - return 3; - } + { + double sqrtQ = Math.sqrt(Q); + double sqrtQ3 = sqrtQ * sqrtQ * sqrtQ; + double theta = Math.acos(R / sqrtQ3); + double norm = -2 * sqrtQ; + res[0] = norm * Math.cos(theta / 3) - a / 3; + res[1] = norm * Math.cos((theta + 2.0 * Math.PI) / 3) - a / 3; + res[2] = norm * Math.cos((theta - 2.0 * Math.PI) / 3) - a / 3; + + // The GNU Scientific Library sorts the results. We don't. + return 3; + } double sgnR = (R >= 0 ? 1 : -1); - double A = -sgnR * Math.pow(Math.abs(R) + Math.sqrt(R2 - Q3), 1.0/3.0); - double B = Q / A ; - res[0] = A + B - a/3; + double A = -sgnR * Math.pow(Math.abs(R) + Math.sqrt(R2 - Q3), 1.0 / 3.0); + double B = Q / A; + res[0] = A + B - a / 3; return 1; } - /** - * Determines whether a position lies inside the area that is bounded + * Determines whether a position lies inside the area bounded * by the curve and the straight line connecting its end points. * *

    A drawing of the area spanned by the curve * *

    The above drawing illustrates in which area points are - * considered “contained” in a CubicCurve2D. + * considered “inside” a CubicCurve2D. */ public boolean contains(double x, double y) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().contains(x, y)) + return false; + return ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0); + } /** - * Determines whether a point lies inside the area that is bounded + * Determines whether a point lies inside the area bounded * by the curve and the straight line connecting its end points. * *

    A drawing of the area spanned by the curve * *

    The above drawing illustrates in which area points are - * considered “contained” in a CubicCurve2D. + * considered “inside” a CubicCurve2D. */ public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); } - + /** + * Determines whether any part of a rectangle is inside the area bounded + * by the curve and the straight line connecting its end points. + * + *

    A drawing of the area spanned by the curve + * + *

    The above drawing illustrates in which area points are + * considered “inside” in a CubicCurve2D. + * @see #contains(double, double) + */ public boolean intersects(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().contains(x, y, w, h)) + return false; + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, true, w) != 0 /* top */ + || getAxisIntersections(x, y + h, true, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, false, h) != 0 /* right */ + || getAxisIntersections(x, y, false, h) != 0) /* left */ + return true; + /* No intersections, is any point inside? */ + if ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0) + return true; + + return false; + } + + /** + * Determines whether any part of a Rectangle2D is inside the area bounded + * by the curve and the straight line connecting its end points. + * @see #intersects(double, double, double, double) + */ public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } - + /** + * Determine whether a rectangle is entirely inside the area that is bounded + * by the curve and the straight line connecting its end points. + * + *

    A drawing of the area spanned by the curve + * + *

    The above drawing illustrates in which area points are + * considered “inside” a CubicCurve2D. + * @see #contains(double, double) + */ public boolean contains(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().intersects(x, y, w, h)) + return false; + + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, true, w) != 0 /* top */ + || getAxisIntersections(x, y + h, true, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, false, h) != 0 /* right */ + || getAxisIntersections(x, y, false, h) != 0) /* left */ + return false; + /* No intersections, is any point inside? */ + if ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0) + return true; + return false; + } + + /** + * Determine whether a Rectangle2D is entirely inside the area that is + * bounded by the curve and the straight line connecting its end points. + * + *

    A drawing of the area spanned by the curve + * + *

    The above drawing illustrates in which area points are + * considered “inside” a CubicCurve2D. + * @see #contains(double, double) + */ public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } - /** * Determines the smallest rectangle that encloses the - * curve’s start, end and control points. As the illustration - * below shows, the invisible control points may cause the bounds to - * be much larger than the area that is actually covered by the - * curve. - * - *

    An illustration of the bounds of a CubicCurve2D + * curve’s start, end and control points. */ public Rectangle getBounds() { return getBounds2D().getBounds(); } - public PathIterator getPathIterator(final AffineTransform at) { return new PathIterator() - { - /** Current coordinate. */ - private int current = 0; - - public int getWindingRule() - { - return WIND_NON_ZERO; - } - - public boolean isDone() - { - return current >= 2; - } - - public void next() - { - current++; - } - - public int currentSegment(float[] coords) { - int result; - switch (current) - { - case 0: - coords[0] = (float) getX1(); - coords[1] = (float) getY1(); - result = SEG_MOVETO; - break; - case 1: - coords[0] = (float) getCtrlX1(); - coords[1] = (float) getCtrlY1(); - coords[2] = (float) getCtrlX2(); - coords[3] = (float) getCtrlY2(); - coords[4] = (float) getX2(); - coords[5] = (float) getY2(); - result = SEG_CUBICTO; - break; - default: - throw new NoSuchElementException("cubic iterator out of bounds"); - } - if (at != null) - at.transform(coords, 0, coords, 0, 3); - return result; - } - - public int currentSegment(double[] coords) - { - int result; - switch (current) - { - case 0: - coords[0] = getX1(); - coords[1] = getY1(); - result = SEG_MOVETO; - break; - case 1: - coords[0] = getCtrlX1(); - coords[1] = getCtrlY1(); - coords[2] = getCtrlX2(); - coords[3] = getCtrlY2(); - coords[4] = getX2(); - coords[5] = getY2(); - result = SEG_CUBICTO; - break; - default: - throw new NoSuchElementException("cubic iterator out of bounds"); - } - if (at != null) - at.transform(coords, 0, coords, 0, 3); - return result; - } - }; + /** Current coordinate. */ + private int current = 0; + + public int getWindingRule() + { + return WIND_NON_ZERO; + } + + public boolean isDone() + { + return current >= 2; + } + + public void next() + { + current++; + } + + public int currentSegment(float[] coords) + { + int result; + switch (current) + { + case 0: + coords[0] = (float) getX1(); + coords[1] = (float) getY1(); + result = SEG_MOVETO; + break; + case 1: + coords[0] = (float) getCtrlX1(); + coords[1] = (float) getCtrlY1(); + coords[2] = (float) getCtrlX2(); + coords[3] = (float) getCtrlY2(); + coords[4] = (float) getX2(); + coords[5] = (float) getY2(); + result = SEG_CUBICTO; + break; + default: + throw new NoSuchElementException("cubic iterator out of bounds"); + } + if (at != null) + at.transform(coords, 0, coords, 0, 3); + return result; + } + + public int currentSegment(double[] coords) + { + int result; + switch (current) + { + case 0: + coords[0] = getX1(); + coords[1] = getY1(); + result = SEG_MOVETO; + break; + case 1: + coords[0] = getCtrlX1(); + coords[1] = getCtrlY1(); + coords[2] = getCtrlX2(); + coords[3] = getCtrlY2(); + coords[4] = getX2(); + coords[5] = getY2(); + result = SEG_CUBICTO; + break; + default: + throw new NoSuchElementException("cubic iterator out of bounds"); + } + if (at != null) + at.transform(coords, 0, coords, 0, 3); + return result; + } + }; } - public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); } - /** * Create a new curve with the same contents as this one. * @@ -976,15 +1016,118 @@ public abstract class CubicCurve2D public Object clone() { try - { - return super.clone(); - } + { + return super.clone(); + } catch (CloneNotSupportedException e) - { - throw (Error) new InternalError().initCause(e); // Impossible - } + { + throw (Error) new InternalError().initCause(e); // Impossible + } } + /** + * Helper method used by contains() and intersects() methods, that + * returns the number of curve/line intersections on a given axis + * extending from a certain point. + * + * @param x x coordinate of the origin point + * @param y y coordinate of the origin point + * @param useYaxis axis used, if true the positive Y axis is used, + * false uses the positive X axis. + * + * This is an implementation of the line-crossings algorithm, + * Detailed in an article on Eric Haines' page: + * http://www.acm.org/tog/editors/erich/ptinpoly/ + * + * A special-case not adressed in this code is self-intersections + * of the curve, e.g. if the axis intersects the self-itersection, + * the degenerate roots of the polynomial will erroneously count as + * a single intersection of the curve, and not two. + */ + private int getAxisIntersections(double x, double y, boolean useYaxis, + double distance) + { + int nCrossings = 0; + double a0; + double a1; + double a2; + double a3; + double b0; + double b1; + double b2; + double b3; + double[] r = new double[4]; + int nRoots; + + a0 = a3 = 0.0; + + if (useYaxis) + { + a0 = getY1() - y; + a1 = getCtrlY1() - y; + a2 = getCtrlY2() - y; + a3 = getY2() - y; + b0 = getX1() - x; + b1 = getCtrlX1() - x; + b2 = getCtrlX2() - x; + b3 = getX2() - x; + } + else + { + a0 = getX1() - x; + a1 = getCtrlX1() - x; + a2 = getCtrlX2() - x; + a3 = getX2() - x; + b0 = getY1() - y; + b1 = getCtrlY1() - y; + b2 = getCtrlY2() - y; + b3 = getY2() - y; + } + + /* If the axis intersects a start/endpoint, shift it up by some small + amount to guarantee the line is 'inside' + If this is not done, bad behaviour may result for points on that axis.*/ + if (a0 == 0.0 || a3 == 0.0) + { + double small = getFlatness() * (1E-10); + if (a0 == 0.0) + a0 += small; + if (a3 == 0.0) + a3 += small; + } + + if (useYaxis) + { + if (Line2D.linesIntersect(b0, a0, b3, a3, 0.0, 0.0, distance, 0.0)) + nCrossings++; + } + else + { + if (Line2D.linesIntersect(a0, b0, a3, b3, 0.0, 0.0, 0.0, distance)) + nCrossings++; + } + + r[0] = a0; + r[1] = 3 * (a1 - a0); + r[2] = 3 * (a2 + a0 - 2 * a1); + r[3] = a3 - 3 * a2 + 3 * a1 - a0; + + if ((nRoots = solveCubic(r)) != 0) + for (int i = 0; i < nRoots; i++) + { + double t = r[i]; + if (t >= 0.0 && t <= 1.0) + { + double crossing = -(t * t * t) * (b0 - 3 * b1 + 3 * b2 - b3) + + 3 * t * t * (b0 - 2 * b1 + b2) + + 3 * t * (b1 - b0) + b0; + if (crossing > 0.0 && crossing <= distance) + nCrossings++; + } + } + + return (nCrossings); + } /** * A two-dimensional curve that is parameterized with a cubic @@ -996,57 +1139,48 @@ public abstract class CubicCurve2D * @author Eric Blake (ebb9@email.byu.edu) * @author Sascha Brawer (brawer@dandelis.ch) */ - public static class Double - extends CubicCurve2D + public static class Double extends CubicCurve2D { /** * The x coordinate of the curve’s start point. */ public double x1; - /** * The y coordinate of the curve’s start point. */ public double y1; - /** * The x coordinate of the curve’s first control point. */ public double ctrlx1; - /** * The y coordinate of the curve’s first control point. */ public double ctrly1; - /** * The x coordinate of the curve’s second control point. */ public double ctrlx2; - /** * The y coordinate of the curve’s second control point. */ public double ctrly2; - /** * The x coordinate of the curve’s end point. */ public double x2; - /** * The y coordinate of the curve’s end point. */ public double y2; - /** * Constructs a new CubicCurve2D that stores its coordinate values * in double-precision floating-point format. All points are @@ -1056,7 +1190,6 @@ public abstract class CubicCurve2D { } - /** * Constructs a new CubicCurve2D that stores its coordinate values * in double-precision floating-point format, specifying the @@ -1089,8 +1222,8 @@ public abstract class CubicCurve2D * @param y2 the y coordinate of the curve’s end * point. */ - public Double(double x1, double y1, double cx1, double cy1, - double cx2, double cy2, double x2, double y2) + public Double(double x1, double y1, double cx1, double cy1, double cx2, + double cy2, double x2, double y2) { this.x1 = x1; this.y1 = y1; @@ -1102,7 +1235,6 @@ public abstract class CubicCurve2D this.y2 = y2; } - /** * Returns the x coordinate of the curve’s start * point. @@ -1112,7 +1244,6 @@ public abstract class CubicCurve2D return x1; } - /** * Returns the y coordinate of the curve’s start * point. @@ -1122,7 +1253,6 @@ public abstract class CubicCurve2D return y1; } - /** * Returns the curve’s start point. */ @@ -1131,7 +1261,6 @@ public abstract class CubicCurve2D return new Point2D.Double(x1, y1); } - /** * Returns the x coordinate of the curve’s first * control point. @@ -1141,7 +1270,6 @@ public abstract class CubicCurve2D return ctrlx1; } - /** * Returns the y coordinate of the curve’s first * control point. @@ -1151,7 +1279,6 @@ public abstract class CubicCurve2D return ctrly1; } - /** * Returns the curve’s first control point. */ @@ -1160,7 +1287,6 @@ public abstract class CubicCurve2D return new Point2D.Double(ctrlx1, ctrly1); } - /** * Returns the x coordinate of the curve’s second * control point. @@ -1170,7 +1296,6 @@ public abstract class CubicCurve2D return ctrlx2; } - /** * Returns the y coordinate of the curve’s second * control point. @@ -1180,7 +1305,6 @@ public abstract class CubicCurve2D return ctrly2; } - /** * Returns the curve’s second control point. */ @@ -1189,7 +1313,6 @@ public abstract class CubicCurve2D return new Point2D.Double(ctrlx2, ctrly2); } - /** * Returns the x coordinate of the curve’s end * point. @@ -1199,7 +1322,6 @@ public abstract class CubicCurve2D return x2; } - /** * Returns the y coordinate of the curve’s end * point. @@ -1209,7 +1331,6 @@ public abstract class CubicCurve2D return y2; } - /** * Returns the curve’s end point. */ @@ -1218,7 +1339,6 @@ public abstract class CubicCurve2D return new Point2D.Double(x2, y2); } - /** * Changes the curve geometry, separately specifying each coordinate * value. @@ -1263,7 +1383,6 @@ public abstract class CubicCurve2D this.y2 = y2; } - /** * Determines the smallest rectangle that encloses the * curve’s start, end and control points. As the @@ -1284,7 +1403,6 @@ public abstract class CubicCurve2D } } - /** * A two-dimensional curve that is parameterized with a cubic * function and stores coordinate values in single-precision @@ -1295,57 +1413,48 @@ public abstract class CubicCurve2D * @author Eric Blake (ebb9@email.byu.edu) * @author Sascha Brawer (brawer@dandelis.ch) */ - public static class Float - extends CubicCurve2D + public static class Float extends CubicCurve2D { /** * The x coordinate of the curve’s start point. */ public float x1; - /** * The y coordinate of the curve’s start point. */ public float y1; - /** * The x coordinate of the curve’s first control point. */ public float ctrlx1; - /** * The y coordinate of the curve’s first control point. */ public float ctrly1; - /** * The x coordinate of the curve’s second control point. */ public float ctrlx2; - /** * The y coordinate of the curve’s second control point. */ public float ctrly2; - /** * The x coordinate of the curve’s end point. */ public float x2; - /** * The y coordinate of the curve’s end point. */ public float y2; - /** * Constructs a new CubicCurve2D that stores its coordinate values * in single-precision floating-point format. All points are @@ -1355,7 +1464,6 @@ public abstract class CubicCurve2D { } - /** * Constructs a new CubicCurve2D that stores its coordinate values * in single-precision floating-point format, specifying the @@ -1388,8 +1496,8 @@ public abstract class CubicCurve2D * @param y2 the y coordinate of the curve’s end * point. */ - public Float(float x1, float y1, float cx1, float cy1, - float cx2, float cy2, float x2, float y2) + public Float(float x1, float y1, float cx1, float cy1, float cx2, + float cy2, float x2, float y2) { this.x1 = x1; this.y1 = y1; @@ -1401,7 +1509,6 @@ public abstract class CubicCurve2D this.y2 = y2; } - /** * Returns the x coordinate of the curve’s start * point. @@ -1411,7 +1518,6 @@ public abstract class CubicCurve2D return x1; } - /** * Returns the y coordinate of the curve’s start * point. @@ -1421,7 +1527,6 @@ public abstract class CubicCurve2D return y1; } - /** * Returns the curve’s start point. */ @@ -1430,7 +1535,6 @@ public abstract class CubicCurve2D return new Point2D.Float(x1, y1); } - /** * Returns the x coordinate of the curve’s first * control point. @@ -1440,7 +1544,6 @@ public abstract class CubicCurve2D return ctrlx1; } - /** * Returns the y coordinate of the curve’s first * control point. @@ -1450,7 +1553,6 @@ public abstract class CubicCurve2D return ctrly1; } - /** * Returns the curve’s first control point. */ @@ -1459,7 +1561,6 @@ public abstract class CubicCurve2D return new Point2D.Float(ctrlx1, ctrly1); } - /** * Returns the s coordinate of the curve’s second * control point. @@ -1469,7 +1570,6 @@ public abstract class CubicCurve2D return ctrlx2; } - /** * Returns the y coordinate of the curve’s second * control point. @@ -1479,7 +1579,6 @@ public abstract class CubicCurve2D return ctrly2; } - /** * Returns the curve’s second control point. */ @@ -1488,7 +1587,6 @@ public abstract class CubicCurve2D return new Point2D.Float(ctrlx2, ctrly2); } - /** * Returns the x coordinate of the curve’s end * point. @@ -1498,7 +1596,6 @@ public abstract class CubicCurve2D return x2; } - /** * Returns the y coordinate of the curve’s end * point. @@ -1508,7 +1605,6 @@ public abstract class CubicCurve2D return y2; } - /** * Returns the curve’s end point. */ @@ -1517,7 +1613,6 @@ public abstract class CubicCurve2D return new Point2D.Float(x2, y2); } - /** * Changes the curve geometry, separately specifying each coordinate * value as a double-precision floating-point number. @@ -1562,7 +1657,6 @@ public abstract class CubicCurve2D this.y2 = (float) y2; } - /** * Changes the curve geometry, separately specifying each coordinate * value as a single-precision floating-point number. @@ -1594,8 +1688,8 @@ public abstract class CubicCurve2D * @param y2 the y coordinate of the curve’s new end * point. */ - public void setCurve(float x1, float y1, float cx1, float cy1, - float cx2, float cy2, float x2, float y2) + public void setCurve(float x1, float y1, float cx1, float cy1, float cx2, + float cy2, float x2, float y2) { this.x1 = x1; this.y1 = y1; @@ -1607,7 +1701,6 @@ public abstract class CubicCurve2D this.y2 = y2; } - /** * Determines the smallest rectangle that encloses the * curve’s start, end and control points. As the diff --git a/libjava/java/awt/geom/GeneralPath.java b/libjava/java/awt/geom/GeneralPath.java index 05d98c76238..40182eabf7e 100644 --- a/libjava/java/awt/geom/GeneralPath.java +++ b/libjava/java/awt/geom/GeneralPath.java @@ -1,50 +1,80 @@ /* GeneralPath.java -- represents a shape built from subpaths - Copyright (C) 2002, 2003 Free Software Foundation - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -02111-1307 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - + Copyright (C) 2002, 2003, 2004 Free Software Foundation + + This file is part of GNU Classpath. + + GNU Classpath is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Classpath is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Classpath; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from + or based on this library. If you modify this library, you may extend + this exception to your version of the library, but you are not + obligated to do so. If you do not wish to do so, delete this + exception statement from your version. */ package java.awt.geom; import java.awt.Rectangle; import java.awt.Shape; + /** - * STUBS ONLY - * XXX Implement and document. Note that Sun's implementation only expects - * float precision, not double. + * A general geometric path, consisting of any number of subpaths + * constructed out of straight lines and cubic or quadratic Bezier + * curves. + * + *

    The inside of the curve is defined for drawing purposes by a winding + * rule. Either the WIND_EVEN_ODD or WIND_NON_ZERO winding rule can be chosen. + * + *

    A drawing of a GeneralPath + *

    The EVEN_ODD winding rule defines a point as inside a path if: + * A ray from the point towards infinity in an arbitrary direction + * intersects the path an odd number of times. Points A and + * C in the image are considered to be outside the path. + * (both intersect twice) + * Point B intersects once, and is inside. + * + *

    The NON_ZERO winding rule defines a point as inside a path if: + * The path intersects the ray in an equal number of opposite directions. + * Point A in the image is outside (one intersection in the + * ’up’ + * direction, one in the ’down’ direction) Point B in + * the image is inside (one intersection ’down’) + * Point C in the image is outside (two intersections + * ’down’) + * + * @see Line2D + * @see CubicCurve2D + * @see QuadCurve2D + * + * @author Sascha Brawer (brawer@dandelis.ch) + * @author Sven de Marothy (sven@physto.se) + * + * @since 1.2 */ public final class GeneralPath implements Shape, Cloneable { @@ -52,35 +82,63 @@ public final class GeneralPath implements Shape, Cloneable public static final int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO; /** Initial size if not specified. */ - private static final int INIT_SIZE = 20; + private static final int INIT_SIZE = 10; + + /** A big number, but not so big it can't survive a few float operations */ + private static final double BIG_VALUE = java.lang.Double.MAX_VALUE / 10.0; /** The winding rule. */ private int rule; + /** - * The path type in points. Note that points[index] maps to - * types[index >> 1]; the control points of quad and cubic paths map as + * The path type in points. Note that xpoints[index] and ypoints[index] maps + * to types[index]; the control points of quad and cubic paths map as * well but are ignored. */ private byte[] types; + /** * The list of all points seen. Since you can only append floats, it makes - * sense for this to be a float[]. I have no idea why Sun didn't choose to + * sense for these to be float[]. I have no idea why Sun didn't choose to * allow a general path of double precision points. + * Note: Storing x and y coords seperately makes for a slower transforms, + * But it speeds up and simplifies box-intersection checking a lot. */ - private float[] points; + private float[] xpoints; + private float[] ypoints; + /** The index of the most recent moveto point, or null. */ private int subpath = -1; + /** The next available index into points. */ private int index; + /** + * Constructs a GeneralPath with the default (NON_ZERO) + * winding rule and initial capacity (20). + */ public GeneralPath() { this(WIND_NON_ZERO, INIT_SIZE); } + + /** + * Constructs a GeneralPath with a specific winding rule + * and the default initial capacity (20). + * @param rule the winding rule (WIND_NON_ZERO or WIND_EVEN_ODD) + */ public GeneralPath(int rule) { this(rule, INIT_SIZE); } + + /** + * Constructs a GeneralPath with a specific winding rule + * and the initial capacity. The initial capacity should be + * the approximate number of path segments to be used. + * @param rule the winding rule (WIND_NON_ZERO or WIND_EVEN_ODD) + * @param capacity the inital capacity, in path segments + */ public GeneralPath(int rule, int capacity) { if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) @@ -88,68 +146,112 @@ public final class GeneralPath implements Shape, Cloneable this.rule = rule; if (capacity < INIT_SIZE) capacity = INIT_SIZE; - types = new byte[capacity >> 1]; - points = new float[capacity]; + types = new byte[capacity]; + xpoints = new float[capacity]; + ypoints = new float[capacity]; } + + /** + * Constructs a GeneralPath from an arbitrary shape object. + * The Shapes PathIterator path and winding rule will be used. + * @param s the shape + */ public GeneralPath(Shape s) { - types = new byte[INIT_SIZE >> 1]; - points = new float[INIT_SIZE]; + types = new byte[INIT_SIZE]; + xpoints = new float[INIT_SIZE]; + ypoints = new float[INIT_SIZE]; PathIterator pi = s.getPathIterator(null); setWindingRule(pi.getWindingRule()); append(pi, false); } + /** + * Adds a new point to a path. + */ public void moveTo(float x, float y) { subpath = index; - ensureSize(index + 2); - types[index >> 1] = PathIterator.SEG_MOVETO; - points[index++] = x; - points[index++] = y; + ensureSize(index + 1); + types[index] = PathIterator.SEG_MOVETO; + xpoints[index] = x; + ypoints[index++] = y; } + + /** + * Appends a straight line to the current path. + * @param x x coordinate of the line endpoint. + * @param y y coordinate of the line endpoint. + */ public void lineTo(float x, float y) { - ensureSize(index + 2); - types[index >> 1] = PathIterator.SEG_LINETO; - points[index++] = x; - points[index++] = y; + ensureSize(index + 1); + types[index] = PathIterator.SEG_LINETO; + xpoints[index] = x; + ypoints[index++] = y; } + + /** + * Appends a quadratic Bezier curve to the current path. + * @param x1 x coordinate of the control point + * @param y1 y coordinate of the control point + * @param x2 x coordinate of the curve endpoint. + * @param y2 y coordinate of the curve endpoint. + */ public void quadTo(float x1, float y1, float x2, float y2) { - ensureSize(index + 4); - types[index >> 1] = PathIterator.SEG_QUADTO; - points[index++] = x1; - points[index++] = y1; - points[index++] = x2; - points[index++] = y2; - } - public void curveTo(float x1, float y1, float x2, float y2, - float x3, float y3) - { - ensureSize(index + 6); - types[index >> 1] = PathIterator.SEG_CUBICTO; - points[index++] = x1; - points[index++] = y1; - points[index++] = x2; - points[index++] = y2; - points[index++] = x3; - points[index++] = y3; + ensureSize(index + 2); + types[index] = PathIterator.SEG_QUADTO; + xpoints[index] = x1; + ypoints[index++] = y1; + xpoints[index] = x2; + ypoints[index++] = y2; } + + /** + * Appends a cubic Bezier curve to the current path. + * @param x1 x coordinate of the first control point + * @param y1 y coordinate of the first control point + * @param x2 x coordinate of the second control point + * @param y2 y coordinate of the second control point + * @param x3 x coordinate of the curve endpoint. + * @param y3 y coordinate of the curve endpoint. + */ + public void curveTo(float x1, float y1, float x2, float y2, float x3, + float y3) + { + ensureSize(index + 3); + types[index] = PathIterator.SEG_CUBICTO; + xpoints[index] = x1; + ypoints[index++] = y1; + xpoints[index] = x2; + ypoints[index++] = y2; + xpoints[index] = x3; + ypoints[index++] = y3; + } + + /** + * Closes the current subpath by drawing a line + * back to the point of the last moveTo. + */ public void closePath() { - ensureSize(index + 2); - types[index >> 1] = PathIterator.SEG_CLOSE; - points[index++] = points[subpath]; - points[index++] = points[subpath + 1]; + ensureSize(index + 1); + types[index] = PathIterator.SEG_CLOSE; + xpoints[index] = xpoints[subpath]; + ypoints[index++] = ypoints[subpath]; } + /** + * Appends the segments of a Shape to the path. If connect is + * true, the new path segments are connected to the existing one with a line. + * The winding rule of the Shape is ignored. + */ public void append(Shape s, boolean connect) { append(s.getPathIterator(null), connect); } - /** * Appends the segments of a PathIterator to this GeneralPath. * Optionally, the initial {@link PathIterator#SEG_MOVETO} segment @@ -158,7 +260,7 @@ public final class GeneralPath implements Shape, Cloneable * * @param iter the PathIterator specifying which segments shall be * appended. - * + * * @param connect true for substituting the initial * {@link PathIterator#SEG_MOVETO} segment by a {@link * PathIterator#SEG_LINETO}, or false for not @@ -171,50 +273,55 @@ public final class GeneralPath implements Shape, Cloneable { // A bad implementation of this method had caused Classpath bug #6076. float[] f = new float[6]; - while (!iter.isDone()) - { - switch (iter.currentSegment(f)) + while (! iter.isDone()) { - case PathIterator.SEG_MOVETO: - if (!connect || (index == 0)) - { - moveTo(f[0], f[1]); - break; - } - - if ((index >= 2) && (types[(index - 2) >> 2] == PathIterator.SEG_CLOSE) - && (f[0] == points[index - 2]) && (f[1] == points[index - 1])) - break; - - // Fall through. - - case PathIterator.SEG_LINETO: - lineTo(f[0], f[1]); - break; - - case PathIterator.SEG_QUADTO: - quadTo(f[0], f[1], f[2], f[3]); - break; - - case PathIterator.SEG_CUBICTO: - curveTo(f[0], f[1], f[2], f[3], f[4], f[5]); - break; - - case PathIterator.SEG_CLOSE: - closePath(); - break; + switch (iter.currentSegment(f)) + { + case PathIterator.SEG_MOVETO: + if (! connect || (index == 0)) + { + moveTo(f[0], f[1]); + break; + } + if ((index >= 1) && (types[index - 1] == PathIterator.SEG_CLOSE) + && (f[0] == xpoints[index - 1]) + && (f[1] == ypoints[index - 1])) + break; + + // Fall through. + case PathIterator.SEG_LINETO: + lineTo(f[0], f[1]); + break; + case PathIterator.SEG_QUADTO: + quadTo(f[0], f[1], f[2], f[3]); + break; + case PathIterator.SEG_CUBICTO: + curveTo(f[0], f[1], f[2], f[3], f[4], f[5]); + break; + case PathIterator.SEG_CLOSE: + closePath(); + break; + } + + connect = false; + iter.next(); } - - connect = false; - iter.next(); - } } - + /** + * Returns the path’s current winding rule. + */ public int getWindingRule() { return rule; } + + /** + * Sets the path’s winding rule, which controls which areas are + * considered ’inside’ or ’outside’ the path + * on drawing. Valid rules are WIND_EVEN_ODD for an even-odd winding rule, + * or WIND_NON_ZERO for a non-zero winding rule. + */ public void setWindingRule(int rule) { if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) @@ -222,22 +329,48 @@ public final class GeneralPath implements Shape, Cloneable this.rule = rule; } + /** + * Returns the current appending point of the path. + */ public Point2D getCurrentPoint() { if (subpath < 0) return null; - return new Point2D.Float(points[index - 2], points[index - 1]); + return new Point2D.Float(xpoints[index - 1], ypoints[index - 1]); } + + /** + * Resets the path. All points and segments are destroyed. + */ public void reset() { subpath = -1; index = 0; } + /** + * Applies a transform to the path. + */ public void transform(AffineTransform xform) { - xform.transform(points, 0, points, 0, index >> 1); + double nx; + double ny; + double[] m = new double[6]; + xform.getMatrix(m); + for (int i = 0; i < index; i++) + { + nx = m[0] * xpoints[i] + m[2] * ypoints[i] + m[4]; + ny = m[1] * xpoints[i] + m[3] * ypoints[i] + m[5]; + xpoints[i] = (float) nx; + ypoints[i] = (float) ny; + } } + + /** + * Creates a transformed version of the path. + * @param xform the transform to apply + * @return a new transformed GeneralPath + */ public Shape createTransformedShape(AffineTransform xform) { GeneralPath p = new GeneralPath(this); @@ -245,85 +378,174 @@ public final class GeneralPath implements Shape, Cloneable return p; } + /** + * Returns the path’s bounding box. + */ public Rectangle getBounds() { return getBounds2D().getBounds(); } + + /** + * Returns the path’s bounding box, in float precision + */ public Rectangle2D getBounds2D() { - // XXX Implement. - throw new Error("not implemented"); + float x1; + float y1; + float x2; + float y2; + + if (index > 0) + { + x1 = x2 = xpoints[0]; + y1 = y2 = ypoints[0]; + } + else + x1 = x2 = y1 = y2 = 0.0f; + + for (int i = 0; i < index; i++) + { + x1 = Math.min(xpoints[i], x1); + y1 = Math.min(ypoints[i], y1); + x2 = Math.max(xpoints[i], x2); + y2 = Math.max(ypoints[i], y2); + } + return (new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1)); } + /** + * Evaluates if a point is within the GeneralPath, + * The NON_ZERO winding rule is used, regardless of the + * set winding rule. + * @param x x coordinate of the point to evaluate + * @param y y coordinate of the point to evaluate + * @return true if the point is within the path, false otherwise + */ public boolean contains(double x, double y) { - // XXX Implement. - throw new Error("not implemented"); + return (getWindingNumber(x, y) != 0); } + + /** + * Evaluates if a Point2D is within the GeneralPath, + * The NON_ZERO winding rule is used, regardless of the + * set winding rule. + * @param p The Point2D to evaluate + * @return true if the point is within the path, false otherwise + */ public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); } + + /** + * Evaluates if a rectangle is completely contained within the path. + * This method will return false in the cases when the box + * intersects an inner segment of the path. + * (i.e.: The method is accurate for the EVEN_ODD winding rule) + */ public boolean contains(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); + if (! getBounds2D().intersects(x, y, w, h)) + return false; + + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, false, w) != 0 /* top */ + || getAxisIntersections(x, y + h, false, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, true, h) != 0 /* right */ + || getAxisIntersections(x, y, true, h) != 0) /* left */ + return false; + + /* No intersections, is any point inside? */ + if (getWindingNumber(x, y) != 0) + return true; + + return false; } + + /** + * Evaluates if a rectangle is completely contained within the path. + * This method will return false in the cases when the box + * intersects an inner segment of the path. + * (i.e.: The method is accurate for the EVEN_ODD winding rule) + * @param r the rectangle + * @return true if the rectangle is completely contained + * within the path, false otherwise + */ public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } + /** + * Evaluates if a rectangle intersects the path. + * @param x x coordinate of the rectangle + * @param y y coordinate of the rectangle + * @param w width of the rectangle + * @param h height of the rectangle + * @return true if the rectangle intersects the path, + * false otherwise + */ public boolean intersects(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, false, w) != 0 /* top */ + || getAxisIntersections(x, y + h, false, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, true, h) != 0 /* right */ + || getAxisIntersections(x, y, true, h) != 0) /* left */ + return true; + + /* No intersections, is any point inside? */ + if (getWindingNumber(x, y) != 0) + return true; + + return false; } + + /** + * Evaluates if a Rectangle2D intersects the path. + * @param r The rectangle + * @return true if the rectangle intersects the path, + * false otherwise + */ public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } - /** * A PathIterator that iterates over the segments of a GeneralPath. * * @author Sascha Brawer (brawer@dandelis.ch) */ - private static class GeneralPathIterator - implements PathIterator + private static class GeneralPathIterator implements PathIterator { /** * The number of coordinate values for each segment type. */ - private static final int[] NUM_COORDS = - { - /* 0: SEG_MOVETO */ 2, - /* 1: SEG_LINETO */ 2, - /* 2: SEG_QUADTO */ 4, - /* 3: SEG_CUBICTO */ 6, - /* 4: SEG_CLOSE */ 0 - }; - + private static final int[] NUM_COORDS = { + /* 0: SEG_MOVETO */ 1, + /* 1: SEG_LINETO */ 1, + /* 2: SEG_QUADTO */ 2, + /* 3: SEG_CUBICTO */ 3, + /* 4: SEG_CLOSE */ 0}; /** * The GeneralPath whose segments are being iterated. */ private final GeneralPath path; - /** * The affine transformation used to transform coordinates. */ private final AffineTransform transform; - /** * The current position of the iterator. */ private int pos; - /** * Constructs a new iterator for enumerating the segments of a * GeneralPath. @@ -338,7 +560,6 @@ public final class GeneralPath implements Shape, Cloneable this.transform = transform; } - /** * Returns the current winding rule of the GeneralPath. */ @@ -347,7 +568,6 @@ public final class GeneralPath implements Shape, Cloneable return path.rule; } - /** * Determines whether the iterator has reached the last segment in * the path. @@ -357,7 +577,6 @@ public final class GeneralPath implements Shape, Cloneable return pos >= path.index; } - /** * Advances the iterator position by one segment. */ @@ -365,70 +584,72 @@ public final class GeneralPath implements Shape, Cloneable { int seg; - /* Increment pos by the number of coordinate values. Note that - * we store two values even for a SEG_CLOSE segment, which is - * why we increment pos at least by 2. + /* + * Increment pos by the number of coordinate pairs. */ - seg = path.types[pos >> 1]; + seg = path.types[pos]; if (seg == SEG_CLOSE) - pos += 2; + pos++; else - pos += NUM_COORDS[seg]; + pos += NUM_COORDS[seg]; } - /** * Returns the current segment in float coordinates. */ public int currentSegment(float[] coords) { - int seg, numCoords; + int seg; + int numCoords; - seg = path.types[pos >> 1]; + seg = path.types[pos]; numCoords = NUM_COORDS[seg]; if (numCoords > 0) - { - if (transform == null) - System.arraycopy(path.points, pos, coords, 0, numCoords); - else - transform.transform(/* src */ path.points, /* srcOffset */ pos, - /* dest */ coords, /* destOffset */ 0, - /* numPoints */ numCoords >> 1); - } + { + for (int i = 0; i < numCoords; i++) + { + coords[i << 1] = path.xpoints[pos + i]; + coords[(i << 1) + 1] = path.ypoints[pos + i]; + } + + if (transform != null) + transform.transform( /* src */ + coords, /* srcOffset */ + 0, /* dest */ coords, /* destOffset */ + 0, /* numPoints */ numCoords); + } return seg; } - /** * Returns the current segment in double coordinates. */ public int currentSegment(double[] coords) { - int seg, numCoords; + int seg; + int numCoords; - seg = path.types[pos >> 1]; + seg = path.types[pos]; numCoords = NUM_COORDS[seg]; if (numCoords > 0) - { - if (transform == null) { - // System.arraycopy throws an exception if the source and destination - // array are not of the same primitive type. - for (int i = 0; i < numCoords; i++) - coords[i] = (double) path.points[pos + i]; + for (int i = 0; i < numCoords; i++) + { + coords[i << 1] = (double) path.xpoints[pos + i]; + coords[(i << 1) + 1] = (double) path.ypoints[pos + i]; + } + if (transform != null) + transform.transform( /* src */ + coords, /* srcOffset */ + pos, /* dest */ coords, /* destOffset */ + 0, /* numPoints */ numCoords); } - else - transform.transform(/* src */ path.points, /* srcOffset */ pos, - /* dest */ coords, /* destOffset */ 0, - /* numPoints */ numCoords >> 1); - } return seg; } } - /** - * Creates a PathIterator for iterating along the segments of this path. + * Creates a PathIterator for iterating along the segments of the path. * * @param at an affine transformation for projecting the returned * points, or null to let the created iterator return @@ -439,15 +660,17 @@ public final class GeneralPath implements Shape, Cloneable return new GeneralPathIterator(this, at); } - + /** + * Creates a new FlatteningPathIterator for the path + */ public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); } /** - * Create a new shape of the same run-time type with the same contents as - * this one. + * Creates a new shape of the same run-time type with the same contents + * as this one. * * @return the clone * @@ -461,17 +684,261 @@ public final class GeneralPath implements Shape, Cloneable return new GeneralPath(this); } + /** + * Helper method - ensure the size of the data arrays, + * otherwise, reallocate new ones twice the size + */ private void ensureSize(int size) { if (subpath < 0) throw new IllegalPathStateException("need initial moveto"); - if (size <= points.length) + if (size <= xpoints.length) return; - byte[] b = new byte[points.length]; - System.arraycopy(types, 0, b, 0, index >> 1); + byte[] b = new byte[types.length << 1]; + System.arraycopy(types, 0, b, 0, index); types = b; - float[] f = new float[points.length << 1]; - System.arraycopy(points, 0, f, 0, index); - points = f; + float[] f = new float[xpoints.length << 1]; + System.arraycopy(xpoints, 0, f, 0, index); + xpoints = f; + f = new float[ypoints.length << 1]; + System.arraycopy(ypoints, 0, f, 0, index); + ypoints = f; + } + + /** + * Helper method - Get the total number of intersections from (x,y) along + * a given axis, within a given distance. + */ + private int getAxisIntersections(double x, double y, boolean useYaxis, + double distance) + { + return (evaluateCrossings(x, y, false, useYaxis, distance)); + } + + /** + * Helper method - returns the winding number of a point. + */ + private int getWindingNumber(double x, double y) + { + /* Evaluate the crossings from x,y to infinity on the y axis (arbitrary + choice). Note that we don't actually use Double.INFINITY, since that's + slower, and may cause problems. */ + return (evaluateCrossings(x, y, true, true, BIG_VALUE)); + } + + /** + * Helper method - evaluates the number of intersections on an axis from + * the point (x,y) to the point (x,y+distance) or (x+distance,y). + * @param x x coordinate. + * @param y y coordinate. + * @param neg True if opposite-directed intersections should cancel, + * false to sum all intersections. + * @param useYaxis Use the Y axis, false uses the X axis. + * @param distance Interval from (x,y) on the selected axis to find + * intersections. + */ + private int evaluateCrossings(double x, double y, boolean neg, + boolean useYaxis, double distance) + { + float cx = 0.0f; + float cy = 0.0f; + float firstx = 0.0f; + float firsty = 0.0f; + + int negative = (neg) ? -1 : 1; + double x0; + double x1; + double x2; + double x3; + double y0; + double y1; + double y2; + double y3; + double[] r = new double[4]; + int nRoots; + double epsilon = 0.0; + int pos = 0; + int windingNumber = 0; + boolean pathStarted = false; + + if (index == 0) + return (0); + if (useYaxis) + { + float[] swap1; + swap1 = ypoints; + ypoints = xpoints; + xpoints = swap1; + double swap2; + swap2 = y; + y = x; + x = swap2; + } + + /* Get a value which is hopefully small but not insignificant relative + the path. */ + epsilon = ypoints[0] * 1E-9; + + pos = 0; + while (pos < index) + { + switch (types[pos]) + { + case PathIterator.SEG_MOVETO: + if (pathStarted) // close old path + { + x0 = cx; + y0 = cy; + x1 = firstx; + y1 = firsty; + + if (y0 == 0.0) + y0 += epsilon; + if (y1 == 0.0) + y1 += epsilon; + if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, + 0.0)) + windingNumber += (y1 < y0) ? 1 : negative; + + cx = firstx; + cy = firsty; + } + cx = firstx = xpoints[pos] - (float) x; + cy = firsty = ypoints[pos++] - (float) y; + pathStarted = true; + break; + case PathIterator.SEG_CLOSE: + x0 = cx; + y0 = cy; + x1 = firstx; + y1 = firsty; + + if (y0 == 0.0) + y0 += epsilon; + if (y1 == 0.0) + y1 += epsilon; + if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) + windingNumber += (y1 < y0) ? 1 : negative; + + cx = firstx; + cy = firsty; + pos++; + pathStarted = false; + break; + case PathIterator.SEG_LINETO: + x0 = cx; + y0 = cy; + x1 = xpoints[pos] - (float) x; + y1 = ypoints[pos++] - (float) y; + + if (y0 == 0.0) + y0 += epsilon; + if (y1 == 0.0) + y1 += epsilon; + if (Line2D.linesIntersect(x0, y0, x1, y1, 0.0, 0.0, distance, 0.0)) + windingNumber += (y1 < y0) ? 1 : negative; + + cx = xpoints[pos - 1] - (float) x; + cy = ypoints[pos - 1] - (float) y; + break; + case PathIterator.SEG_QUADTO: + x0 = cx; + y0 = cy; + x1 = xpoints[pos] - x; + y1 = ypoints[pos++] - y; + x2 = xpoints[pos] - x; + y2 = ypoints[pos++] - y; + + /* check if curve may intersect X+ axis. */ + if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0) + && (y0 * y1 <= 0 || y1 * y2 <= 0)) + { + if (y0 == 0.0) + y0 += epsilon; + if (y2 == 0.0) + y2 += epsilon; + + r[0] = y0; + r[1] = 2 * (y1 - y0); + r[2] = (y2 - 2 * y1 + y0); + + /* degenerate roots (=tangent points) do not + contribute to the winding number. */ + if ((nRoots = QuadCurve2D.solveQuadratic(r)) == 2) + for (int i = 0; i < nRoots; i++) + { + float t = (float) r[i]; + if (t > 0.0f && t < 1.0f) + { + double crossing = t * t * (x2 - 2 * x1 + x0) + + 2 * t * (x1 - x0) + x0; + if (crossing >= 0.0 && crossing <= distance) + windingNumber += (2 * t * (y2 - 2 * y1 + y0) + + 2 * (y1 - y0) < 0) ? 1 : negative; + } + } + } + + cx = xpoints[pos - 1] - (float) x; + cy = ypoints[pos - 1] - (float) y; + break; + case PathIterator.SEG_CUBICTO: + x0 = cx; + y0 = cy; + x1 = xpoints[pos] - x; + y1 = ypoints[pos++] - y; + x2 = xpoints[pos] - x; + y2 = ypoints[pos++] - y; + x3 = xpoints[pos] - x; + y3 = ypoints[pos++] - y; + + /* check if curve may intersect X+ axis. */ + if ((x0 > 0.0 || x1 > 0.0 || x2 > 0.0 || x3 > 0.0) + && (y0 * y1 <= 0 || y1 * y2 <= 0 || y2 * y3 <= 0)) + { + if (y0 == 0.0) + y0 += epsilon; + if (y3 == 0.0) + y3 += epsilon; + + r[0] = y0; + r[1] = 3 * (y1 - y0); + r[2] = 3 * (y2 + y0 - 2 * y1); + r[3] = y3 - 3 * y2 + 3 * y1 - y0; + + if ((nRoots = CubicCurve2D.solveCubic(r)) != 0) + for (int i = 0; i < nRoots; i++) + { + float t = (float) r[i]; + if (t > 0.0 && t < 1.0) + { + double crossing = -(t * t * t) * (x0 - 3 * x1 + + 3 * x2 - x3) + + 3 * t * t * (x0 - 2 * x1 + x2) + + 3 * t * (x1 - x0) + x0; + if (crossing >= 0 && crossing <= distance) + windingNumber += (3 * t * t * (y3 + 3 * y1 + - 3 * y2 - y0) + + 6 * t * (y0 - 2 * y1 + y2) + + 3 * (y1 - y0) < 0) ? 1 : negative; + } + } + } + + cx = xpoints[pos - 1] - (float) x; + cy = ypoints[pos - 1] - (float) y; + break; + } + } + + // swap coordinates back + if (useYaxis) + { + float[] swap; + swap = ypoints; + ypoints = xpoints; + xpoints = swap; + } + return (windingNumber); } } // class GeneralPath diff --git a/libjava/java/awt/geom/QuadCurve2D.java b/libjava/java/awt/geom/QuadCurve2D.java index 409c4841e15..0cc9eb46edc 100644 --- a/libjava/java/awt/geom/QuadCurve2D.java +++ b/libjava/java/awt/geom/QuadCurve2D.java @@ -1,5 +1,5 @@ /* QuadCurve2D.java -- represents a parameterized quadratic curve in 2-D space - Copyright (C) 2002, 2003 Free Software Foundation + Copyright (C) 2002, 2003, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -35,7 +35,6 @@ 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.geom; import java.awt.Rectangle; @@ -53,12 +52,14 @@ import java.util.NoSuchElementException; * @author Eric Blake (ebb9@email.byu.edu) * @author Graydon Hoare (graydon@redhat.com) * @author Sascha Brawer (brawer@dandelis.ch) + * @author Sven de Marothy (sven@physto.se) * * @since 1.2 */ -public abstract class QuadCurve2D - implements Shape, Cloneable +public abstract class QuadCurve2D implements Shape, Cloneable { + private static final double BIG_VALUE = java.lang.Double.MAX_VALUE / 10.0; + /** * Constructs a new QuadCurve2D. Typical users will want to * construct instances of a subclass, such as {@link @@ -68,67 +69,57 @@ public abstract class QuadCurve2D { } - /** * Returns the x coordinate of the curve’s start * point. */ public abstract double getX1(); - /** * Returns the y coordinate of the curve’s start * point. */ public abstract double getY1(); - /** * Returns the curve’s start point. */ public abstract Point2D getP1(); - /** * Returns the x coordinate of the curve’s control * point. */ public abstract double getCtrlX(); - /** * Returns the y coordinate of the curve’s control * point. */ public abstract double getCtrlY(); - /** * Returns the curve’s control point. */ public abstract Point2D getCtrlPt(); - /** * Returns the x coordinate of the curve’s end * point. */ public abstract double getX2(); - /** * Returns the y coordinate of the curve’s end * point. */ public abstract double getY2(); - /** * Returns the curve’s end point. */ public abstract Point2D getP2(); - /** * Changes the curve geometry, separately specifying each coordinate * value. @@ -154,7 +145,6 @@ public abstract class QuadCurve2D public abstract void setCurve(double x1, double y1, double cx, double cy, double x2, double y2); - /** * Changes the curve geometry, passing coordinate values in an * array. @@ -174,12 +164,10 @@ public abstract class QuadCurve2D */ public void setCurve(double[] coords, int offset) { - setCurve(coords[offset++], coords[offset++], - coords[offset++], coords[offset++], - coords[offset++], coords[offset++]); + setCurve(coords[offset++], coords[offset++], coords[offset++], + coords[offset++], coords[offset++], coords[offset++]); } - /** * Changes the curve geometry, specifying coordinate values in * separate Point objects. @@ -198,11 +186,9 @@ public abstract class QuadCurve2D */ public void setCurve(Point2D p1, Point2D c, Point2D p2) { - setCurve(p1.getX(), p1.getY(), c.getX(), c.getY(), - p2.getX(), p2.getY()); + setCurve(p1.getX(), p1.getY(), c.getX(), c.getY(), p2.getX(), p2.getY()); } - /** * Changes the curve geometry, specifying coordinate values in an * array of Point objects. @@ -223,12 +209,11 @@ public abstract class QuadCurve2D */ public void setCurve(Point2D[] pts, int offset) { - setCurve(pts[offset].getX(), pts[offset].getY(), - pts[offset + 1].getX(), pts[offset + 1].getY(), - pts[offset + 2].getX(), pts[offset + 2].getY()); + setCurve(pts[offset].getX(), pts[offset].getY(), pts[offset + 1].getX(), + pts[offset + 1].getY(), pts[offset + 2].getX(), + pts[offset + 2].getY()); } - /** * Changes the geometry of the curve to that of another curve. * @@ -236,11 +221,10 @@ public abstract class QuadCurve2D */ public void setCurve(QuadCurve2D c) { - setCurve(c.getX1(), c.getY1(), c.getCtrlX(), c.getCtrlY(), - c.getX2(), c.getY2()); + setCurve(c.getX1(), c.getY1(), c.getCtrlX(), c.getCtrlY(), c.getX2(), + c.getY2()); } - /** * Calculates the squared flatness of a quadratic curve, directly * specifying each coordinate value. The flatness is the distance of @@ -267,7 +251,6 @@ public abstract class QuadCurve2D return Line2D.ptSegDistSq(x1, y1, x2, y2, cx, cy); } - /** * Calculates the flatness of a quadratic curve, directly specifying * each coordinate value. The flatness is the distance of the @@ -294,7 +277,6 @@ public abstract class QuadCurve2D return Line2D.ptSegDist(x1, y1, x2, y2, cx, cy); } - /** * Calculates the squared flatness of a quadratic curve, specifying * the coordinate values in an array. The flatness is the distance @@ -328,7 +310,6 @@ public abstract class QuadCurve2D coords[offset + 2], coords[offset + 3]); } - /** * Calculates the flatness of a quadratic curve, specifying the * coordinate values in an array. The flatness is the distance of @@ -362,7 +343,6 @@ public abstract class QuadCurve2D coords[offset + 2], coords[offset + 3]); } - /** * Calculates the squared flatness of this curve. The flatness is * the distance of the control point to the line between start and @@ -378,12 +358,10 @@ public abstract class QuadCurve2D */ public double getFlatnessSq() { - return Line2D.ptSegDistSq(getX1(), getY1(), - getX2(), getY2(), - getCtrlX(), getCtrlY()); + return Line2D.ptSegDistSq(getX1(), getY1(), getX2(), getY2(), getCtrlX(), + getCtrlY()); } - /** * Calculates the flatness of this curve. The flatness is the * distance of the control point to the line between start and end @@ -399,12 +377,10 @@ public abstract class QuadCurve2D */ public double getFlatness() { - return Line2D.ptSegDist(getX1(), getY1(), - getX2(), getY2(), - getCtrlX(), getCtrlY()); + return Line2D.ptSegDist(getX1(), getY1(), getX2(), getY2(), getCtrlX(), + getCtrlY()); } - /** * Subdivides this curve into two halves. * @@ -423,8 +399,11 @@ public abstract class QuadCurve2D public void subdivide(QuadCurve2D left, QuadCurve2D right) { // Use empty slots at end to share single array. - double[] d = new double[] { getX1(), getY1(), getCtrlX(), getCtrlY(), - getX2(), getY2(), 0, 0, 0, 0 }; + double[] d = new double[] + { + getX1(), getY1(), getCtrlX(), getCtrlY(), getX2(), getY2(), + 0, 0, 0, 0 + }; subdivide(d, 0, d, 0, d, 4); if (left != null) left.setCurve(d, 0); @@ -432,7 +411,6 @@ public abstract class QuadCurve2D right.setCurve(d, 4); } - /** * Subdivides a quadratic curve into two halves. * @@ -456,7 +434,6 @@ public abstract class QuadCurve2D src.subdivide(left, right); } - /** * Subdivides a quadratic curve into two halves, passing all * coordinates in an array. @@ -500,11 +477,15 @@ public abstract class QuadCurve2D * index where the start point’s x coordinate will be * stored. */ - public static void subdivide(double[] src, int srcOff, - double[] left, int leftOff, - double[] right, int rightOff) + public static void subdivide(double[] src, int srcOff, double[] left, + int leftOff, double[] right, int rightOff) { - double x1, y1, xc, yc, x2, y2; + double x1; + double y1; + double xc; + double yc; + double x2; + double y2; x1 = src[srcOff]; y1 = src[srcOff + 1]; @@ -514,16 +495,16 @@ public abstract class QuadCurve2D y2 = src[srcOff + 5]; if (left != null) - { - left[leftOff] = x1; - left[leftOff + 1] = y1; - } + { + left[leftOff] = x1; + left[leftOff + 1] = y1; + } if (right != null) - { - right[rightOff + 4] = x2; - right[rightOff + 5] = y2; - } + { + right[rightOff + 4] = x2; + right[rightOff + 5] = y2; + } x1 = (x1 + xc) / 2; x2 = (xc + x2) / 2; @@ -533,23 +514,22 @@ public abstract class QuadCurve2D yc = (y1 + y2) / 2; if (left != null) - { - left[leftOff + 2] = x1; - left[leftOff + 3] = y1; - left[leftOff + 4] = xc; - left[leftOff + 5] = yc; - } + { + left[leftOff + 2] = x1; + left[leftOff + 3] = y1; + left[leftOff + 4] = xc; + left[leftOff + 5] = yc; + } if (right != null) - { - right[rightOff] = xc; - right[rightOff + 1] = yc; - right[rightOff + 2] = x2; - right[rightOff + 3] = y2; - } + { + right[rightOff] = xc; + right[rightOff + 1] = yc; + right[rightOff + 2] = x2; + right[rightOff + 3] = y2; + } } - /** * Finds the non-complex roots of a quadratic equation, placing the * results into the same array as the equation coefficients. The @@ -594,7 +574,6 @@ public abstract class QuadCurve2D return solveQuadratic(eqn, eqn); } - /** * Finds the non-complex roots of a quadratic equation. The * following equation is being solved: @@ -649,8 +628,10 @@ public abstract class QuadCurve2D // The Java implementation is very similar to the GSL code, but // not a strict one-to-one copy. For example, GSL would sort the // result. - - double a, b, c, disc; + double a; + double b; + double c; + double disc; c = eqn[0]; b = eqn[1]; @@ -661,13 +642,13 @@ public abstract class QuadCurve2D // wouldn't return -1 for constant functions, and 2 instead of 1 // for linear functions. if (a == 0) - { - if (b == 0) - return -1; - - res[0] = -c / b; - return 1; - } + { + if (b == 0) + return -1; + + res[0] = -c / b; + return 1; + } disc = b * b - 4 * a * c; @@ -675,96 +656,149 @@ public abstract class QuadCurve2D return 0; if (disc == 0) - { - // The GNU Scientific Library returns two identical results here. - // We just return one. - res[0] = -0.5 * b / a ; - return 1; - } + { + // The GNU Scientific Library returns two identical results here. + // We just return one. + res[0] = -0.5 * b / a; + return 1; + } // disc > 0 if (b == 0) - { - double r; + { + double r; - r = Math.abs(0.5 * Math.sqrt(disc) / a); - res[0] = -r; - res[1] = r; - } + r = Math.abs(0.5 * Math.sqrt(disc) / a); + res[0] = -r; + res[1] = r; + } else - { - double sgnb, temp; - - sgnb = (b > 0 ? 1 : -1); - temp = -0.5 * (b + sgnb * Math.sqrt(disc)); - - // The GNU Scientific Library sorts the result here. We don't. - res[0] = temp / a; - res[1] = c / temp; - } + { + double sgnb; + double temp; + + sgnb = (b > 0 ? 1 : -1); + temp = -0.5 * (b + sgnb * Math.sqrt(disc)); + + // The GNU Scientific Library sorts the result here. We don't. + res[0] = temp / a; + res[1] = c / temp; + } return 2; } - /** - * Determines whether a point lies inside the area that is bounded + * Determines whether a point is inside the area bounded * by the curve and the straight line connecting its end points. * *

    A drawing of the area spanned by the curve * *

    The above drawing illustrates in which area points are - * considered “contained” in a QuadCurve2D. + * considered “inside” a QuadCurve2D. */ public boolean contains(double x, double y) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().contains(x, y)) + return false; + return ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0); + } /** - * Determines whether a point lies inside the area that is bounded + * Determines whether a point is inside the area bounded * by the curve and the straight line connecting its end points. * *

    A drawing of the area spanned by the curve * *

    The above drawing illustrates in which area points are - * considered “contained” in a QuadCurve2D. + * considered “inside” a QuadCurve2D. */ public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); } - + /** + * Determines whether any part of a rectangle is inside the area bounded + * by the curve and the straight line connecting its end points. + * + *

    A drawing of the area spanned by the curve + * + *

    The above drawing illustrates in which area points are + * considered “inside” in a CubicCurve2D. + */ public boolean intersects(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().contains(x, y, w, h)) + return false; + + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, true, w) != 0 /* top */ + || getAxisIntersections(x, y + h, true, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, false, h) != 0 /* right */ + || getAxisIntersections(x, y, false, h) != 0) /* left */ + return true; + + /* No intersections, is any point inside? */ + if ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0) + return true; + return false; + } + /** + * Determines whether any part of a Rectangle2D is inside the area bounded + * by the curve and the straight line connecting its end points. + * @see #intersects(double, double, double, double) + */ public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } - + /** + * Determines whether a rectangle is entirely inside the area bounded + * by the curve and the straight line connecting its end points. + * + *

    A drawing of the area spanned by the curve + * + *

    The above drawing illustrates in which area points are + * considered “inside” a QuadCurve2D. + * @see #contains(double, double) + */ public boolean contains(double x, double y, double w, double h) { - // XXX Implement. - throw new Error("not implemented"); - } + if (! getBounds2D().intersects(x, y, w, h)) + return false; + + /* Does any edge intersect? */ + if (getAxisIntersections(x, y, true, w) != 0 /* top */ + || getAxisIntersections(x, y + h, true, w) != 0 /* bottom */ + || getAxisIntersections(x + w, y, false, h) != 0 /* right */ + || getAxisIntersections(x, y, false, h) != 0) /* left */ + return false; + /* No intersections, is any point inside? */ + if ((getAxisIntersections(x, y, true, BIG_VALUE) & 1) != 0) + return true; + return false; + } + + /** + * Determines whether a Rectangle2D is entirely inside the area that is + * bounded by the curve and the straight line connecting its end points. + * @see #contains(double, double, double, double) + */ public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } - /** * Determines the smallest rectangle that encloses the * curve’s start, end and control point. As the illustration @@ -780,97 +814,85 @@ public abstract class QuadCurve2D return getBounds2D().getBounds(); } - public PathIterator getPathIterator(final AffineTransform at) { return new PathIterator() - { - /** Current coordinate. */ - private int current = 0; - - - public int getWindingRule() - { - return WIND_NON_ZERO; - } - - - public boolean isDone() - { - return current >= 2; - } - - - public void next() - { - current++; - } - - - public int currentSegment(float[] coords) { - int result; - switch (current) - { - case 0: - coords[0] = (float) getX1(); - coords[1] = (float) getY1(); - result = SEG_MOVETO; - break; - - case 1: - coords[0] = (float) getCtrlX(); - coords[1] = (float) getCtrlY(); - coords[2] = (float) getX2(); - coords[3] = (float) getY2(); - result = SEG_QUADTO; - break; - - default: - throw new NoSuchElementException("quad iterator out of bounds"); - } - if (at != null) - at.transform(coords, 0, coords, 0, 2); - return result; - } - - - public int currentSegment(double[] coords) - { - int result; - switch (current) - { - case 0: - coords[0] = getX1(); - coords[1] = getY1(); - result = SEG_MOVETO; - break; - - case 1: - coords[0] = getCtrlX(); - coords[1] = getCtrlY(); - coords[2] = getX2(); - coords[3] = getY2(); - result = SEG_QUADTO; - break; - - default: - throw new NoSuchElementException("quad iterator out of bounds"); - } - if (at != null) - at.transform(coords, 0, coords, 0, 2); - return result; - } - }; + /** Current coordinate. */ + private int current = 0; + + public int getWindingRule() + { + return WIND_NON_ZERO; + } + + public boolean isDone() + { + return current >= 2; + } + + public void next() + { + current++; + } + + public int currentSegment(float[] coords) + { + int result; + switch (current) + { + case 0: + coords[0] = (float) getX1(); + coords[1] = (float) getY1(); + result = SEG_MOVETO; + break; + case 1: + coords[0] = (float) getCtrlX(); + coords[1] = (float) getCtrlY(); + coords[2] = (float) getX2(); + coords[3] = (float) getY2(); + result = SEG_QUADTO; + break; + default: + throw new NoSuchElementException("quad iterator out of bounds"); + } + if (at != null) + at.transform(coords, 0, coords, 0, 2); + return result; + } + + public int currentSegment(double[] coords) + { + int result; + switch (current) + { + case 0: + coords[0] = getX1(); + coords[1] = getY1(); + result = SEG_MOVETO; + break; + case 1: + coords[0] = getCtrlX(); + coords[1] = getCtrlY(); + coords[2] = getX2(); + coords[3] = getY2(); + result = SEG_QUADTO; + break; + default: + throw new NoSuchElementException("quad iterator out of bounds"); + } + if (at != null) + at.transform(coords, 0, coords, 0, 2); + return result; + } + }; } - public PathIterator getPathIterator(AffineTransform at, double flatness) { return new FlatteningPathIterator(getPathIterator(at), flatness); } - /** * Creates a new curve with the same contents as this one. * @@ -879,15 +901,106 @@ public abstract class QuadCurve2D public Object clone() { try - { - return super.clone(); - } + { + return super.clone(); + } catch (CloneNotSupportedException e) - { - throw (Error) new InternalError().initCause(e); // Impossible - } + { + throw (Error) new InternalError().initCause(e); // Impossible + } } + /** + * Helper method used by contains() and intersects() methods + * Return the number of curve/line intersections on a given axis + * extending from a certain point. useYaxis is true for using the Y axis, + * @param x x coordinate of the origin point + * @param y y coordinate of the origin point + * @param useYaxis axis to follow, if true the positive Y axis is used, + * false uses the positive X axis. + * + * This is an implementation of the line-crossings algorithm, + * Detailed in an article on Eric Haines' page: + * http://www.acm.org/tog/editors/erich/ptinpoly/ + */ + private int getAxisIntersections(double x, double y, boolean useYaxis, + double distance) + { + int nCrossings = 0; + double a0; + double a1; + double a2; + double b0; + double b1; + double b2; + double[] r = new double[3]; + int nRoots; + + a0 = a2 = 0.0; + + if (useYaxis) + { + a0 = getY1() - y; + a1 = getCtrlY() - y; + a2 = getY2() - y; + b0 = getX1() - x; + b1 = getCtrlX() - x; + b2 = getX2() - x; + } + else + { + a0 = getX1() - x; + a1 = getCtrlX() - x; + a2 = getX2() - x; + b0 = getY1() - y; + b1 = getCtrlY() - y; + b2 = getY2() - y; + } + + /* If the axis intersects a start/endpoint, shift it up by some small + amount to guarantee the line is 'inside' + If this is not done,bad behaviour may result for points on that axis. */ + if (a0 == 0.0 || a2 == 0.0) + { + double small = getFlatness() * (1E-10); + if (a0 == 0.0) + a0 += small; + + if (a2 == 0.0) + a2 += small; + } + + r[0] = a0; + r[1] = 2 * (a1 - a0); + r[2] = (a2 - 2 * a1 + a0); + + nRoots = solveQuadratic(r); + for (int i = 0; i < nRoots; i++) + { + double t = r[i]; + if (t >= 0.0 && t <= 1.0) + { + double crossing = t * t * (b2 - 2 * b1 + b0) + 2 * t * (b1 - b0) + + b0; + /* single root is always doubly degenerate in quads */ + if (crossing > 0 && crossing < distance) + nCrossings += (nRoots == 1) ? 2 : 1; + } + } + + if (useYaxis) + { + if (Line2D.linesIntersect(b0, a0, b2, a2, 0.0, 0.0, distance, 0.0)) + nCrossings++; + } + else + { + if (Line2D.linesIntersect(a0, b0, a2, b2, 0.0, 0.0, 0.0, distance)) + nCrossings++; + } + + return (nCrossings); + } /** * A two-dimensional curve that is parameterized with a quadratic @@ -899,45 +1012,38 @@ public abstract class QuadCurve2D * @author Eric Blake (ebb9@email.byu.edu) * @author Sascha Brawer (brawer@dandelis.ch) */ - public static class Double - extends QuadCurve2D + public static class Double extends QuadCurve2D { /** * The x coordinate of the curve’s start point. */ public double x1; - /** * The y coordinate of the curve’s start point. */ public double y1; - /** * The x coordinate of the curve’s control point. */ public double ctrlx; - /** * The y coordinate of the curve’s control point. */ public double ctrly; - /** * The x coordinate of the curve’s end point. */ public double x2; - /** * The y coordinate of the curve’s end point. */ public double y2; - /** * Constructs a new QuadCurve2D that stores its coordinate values * in double-precision floating-point format. All points are @@ -947,7 +1053,6 @@ public abstract class QuadCurve2D { } - /** * Constructs a new QuadCurve2D that stores its coordinate values * in double-precision floating-point format, specifying the @@ -971,8 +1076,8 @@ public abstract class QuadCurve2D * @param y2 the y coordinate of the curve’s end * point. */ - public Double(double x1, double y1, double cx, double cy, - double x2, double y2) + public Double(double x1, double y1, double cx, double cy, double x2, + double y2) { this.x1 = x1; this.y1 = y1; @@ -982,7 +1087,6 @@ public abstract class QuadCurve2D this.y2 = y2; } - /** * Returns the x coordinate of the curve’s start * point. @@ -992,7 +1096,6 @@ public abstract class QuadCurve2D return x1; } - /** * Returns the y coordinate of the curve’s start * point. @@ -1002,7 +1105,6 @@ public abstract class QuadCurve2D return y1; } - /** * Returns the curve’s start point. */ @@ -1011,7 +1113,6 @@ public abstract class QuadCurve2D return new Point2D.Double(x1, y1); } - /** * Returns the x coordinate of the curve’s control * point. @@ -1021,7 +1122,6 @@ public abstract class QuadCurve2D return ctrlx; } - /** * Returns the y coordinate of the curve’s control * point. @@ -1031,7 +1131,6 @@ public abstract class QuadCurve2D return ctrly; } - /** * Returns the curve’s control point. */ @@ -1040,7 +1139,6 @@ public abstract class QuadCurve2D return new Point2D.Double(ctrlx, ctrly); } - /** * Returns the x coordinate of the curve’s end * point. @@ -1050,7 +1148,6 @@ public abstract class QuadCurve2D return x2; } - /** * Returns the y coordinate of the curve’s end * point. @@ -1060,7 +1157,6 @@ public abstract class QuadCurve2D return y2; } - /** * Returns the curve’s end point. */ @@ -1069,7 +1165,6 @@ public abstract class QuadCurve2D return new Point2D.Double(x2, y2); } - /** * Changes the geometry of the curve. * @@ -1102,7 +1197,6 @@ public abstract class QuadCurve2D this.y2 = y2; } - /** * Determines the smallest rectangle that encloses the * curve’s start, end and control point. As the @@ -1123,7 +1217,6 @@ public abstract class QuadCurve2D } } - /** * A two-dimensional curve that is parameterized with a quadratic * function and stores coordinate values in single-precision @@ -1134,45 +1227,38 @@ public abstract class QuadCurve2D * @author Eric Blake (ebb9@email.byu.edu) * @author Sascha Brawer (brawer@dandelis.ch) */ - public static class Float - extends QuadCurve2D + public static class Float extends QuadCurve2D { /** * The x coordinate of the curve’s start point. */ public float x1; - /** * The y coordinate of the curve’s start point. */ public float y1; - /** * The x coordinate of the curve’s control point. */ public float ctrlx; - /** * The y coordinate of the curve’s control point. */ public float ctrly; - /** * The x coordinate of the curve’s end point. */ public float x2; - /** * The y coordinate of the curve’s end point. */ public float y2; - /** * Constructs a new QuadCurve2D that stores its coordinate values * in single-precision floating-point format. All points are @@ -1182,7 +1268,6 @@ public abstract class QuadCurve2D { } - /** * Constructs a new QuadCurve2D that stores its coordinate values * in single-precision floating-point format, specifying the @@ -1206,8 +1291,7 @@ public abstract class QuadCurve2D * @param y2 the y coordinate of the curve’s end * point. */ - public Float(float x1, float y1, float cx, float cy, - float x2, float y2) + public Float(float x1, float y1, float cx, float cy, float x2, float y2) { this.x1 = x1; this.y1 = y1; @@ -1217,7 +1301,6 @@ public abstract class QuadCurve2D this.y2 = y2; } - /** * Returns the x coordinate of the curve’s start * point. @@ -1227,7 +1310,6 @@ public abstract class QuadCurve2D return x1; } - /** * Returns the y coordinate of the curve’s start * point. @@ -1237,7 +1319,6 @@ public abstract class QuadCurve2D return y1; } - /** * Returns the curve’s start point. */ @@ -1246,7 +1327,6 @@ public abstract class QuadCurve2D return new Point2D.Float(x1, y1); } - /** * Returns the x coordinate of the curve’s control * point. @@ -1256,7 +1336,6 @@ public abstract class QuadCurve2D return ctrlx; } - /** * Returns the y coordinate of the curve’s control * point. @@ -1266,7 +1345,6 @@ public abstract class QuadCurve2D return ctrly; } - /** * Returns the curve’s control point. */ @@ -1275,7 +1353,6 @@ public abstract class QuadCurve2D return new Point2D.Float(ctrlx, ctrly); } - /** * Returns the x coordinate of the curve’s end * point. @@ -1285,7 +1362,6 @@ public abstract class QuadCurve2D return x2; } - /** * Returns the y coordinate of the curve’s end * point. @@ -1295,7 +1371,6 @@ public abstract class QuadCurve2D return y2; } - /** * Returns the curve’s end point. */ @@ -1304,7 +1379,6 @@ public abstract class QuadCurve2D return new Point2D.Float(x2, y2); } - /** * Changes the geometry of the curve, specifying coordinate values * as double-precision floating-point numbers. @@ -1338,7 +1412,6 @@ public abstract class QuadCurve2D this.y2 = (float) y2; } - /** * Changes the geometry of the curve, specifying coordinate values * as single-precision floating-point numbers. @@ -1361,8 +1434,8 @@ public abstract class QuadCurve2D * @param y2 the y coordinate of the curve’s new * end point. */ - public void setCurve(float x1, float y1, float cx, float cy, - float x2, float y2) + public void setCurve(float x1, float y1, float cx, float cy, float x2, + float y2) { this.x1 = x1; this.y1 = y1; @@ -1372,7 +1445,6 @@ public abstract class QuadCurve2D this.y2 = y2; } - /** * Determines the smallest rectangle that encloses the * curve’s start, end and control point. As the diff --git a/libjava/java/awt/geom/RoundRectangle2D.java b/libjava/java/awt/geom/RoundRectangle2D.java index 3a7899d3ed5..3f004ed6bbc 100644 --- a/libjava/java/awt/geom/RoundRectangle2D.java +++ b/libjava/java/awt/geom/RoundRectangle2D.java @@ -1,5 +1,5 @@ /* RoundRectangle2D.java -- represents a rectangle with rounded corners - Copyright (C) 2000, 2002, 2003 Free Software Foundation + Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation This file is part of GNU Classpath. @@ -39,6 +39,7 @@ package java.awt.geom; import java.util.NoSuchElementException; + /** This class implements a rectangle with rounded corners. * @author Tom Tromey * @date December 3, 2000 @@ -60,12 +61,12 @@ public abstract class RoundRectangle2D extends RectangularShape * @param arcHeight The arc height */ public abstract void setRoundRect(double x, double y, double w, double h, - double arcWidth, double arcHeight); + double arcWidth, double arcHeight); /** Create a RoundRectangle2D. This is protected because this class * is abstract and cannot be instantiated. */ - protected RoundRectangle2D() + protected RoundRectangle2D() { } @@ -87,8 +88,11 @@ public abstract class RoundRectangle2D extends RectangularShape // Now check to see if the point is in range of an arc. double dy = Math.min(Math.abs(my - y), Math.abs(my + mh - y)); double dx = Math.min(Math.abs(mx - x), Math.abs(mx + mw - x)); - double aw = getArcWidth(); - double ah = getArcHeight(); + + // The arc dimensions are that of the corresponding ellipse + // thus a 90 degree segment is half of that. + double aw = getArcWidth() / 2.0; + double ah = getArcHeight() / 2.0; if (dx > aw || dy > ah) return true; @@ -112,8 +116,8 @@ public abstract class RoundRectangle2D extends RectangularShape { // We have to check all four points here (for ordinary rectangles // we can just check opposing corners). - return (contains(x, y) && contains(x + w, h) - && contains(x, y + h) && contains(x + w, y + h)); + return (contains(x, y) && contains(x, y + h) && contains(x + w, y + h) + && contains(x + w, y)); } /** Return a new path iterator which iterates over this rectangle. @@ -128,154 +132,161 @@ public abstract class RoundRectangle2D extends RectangularShape final double arcwidth = getArcWidth(); final double archeight = getArcHeight(); return new PathIterator() - { - /** We iterate clockwise around the rectangle, starting in the - * upper left. This variable tracks our current point, which - * can be on either side of a given corner. */ - private int current = 0; - - /** Child path iterator, used for corners. */ - private PathIterator corner; - - /** This is used when rendering the corners. We re-use the arc - * for each corner. */ - private Arc2D arc = new Arc2D.Double(); - - /** Temporary array used by getPoint. */ - private double[] temp = new double[2]; - - public int getWindingRule() { - return WIND_NON_ZERO; - } - - public boolean isDone() - { - return current > 9; - } - - private void getPoint(int val) - { - switch (val) - { - case 0: - case 8: - temp[0] = minx; - temp[1] = miny + archeight; - break; - case 1: - temp[0] = minx + arcwidth; - temp[1] = miny; - break; - case 2: - temp[0] = maxx - arcwidth; - temp[1] = maxy; - break; - case 3: - temp[0] = maxx; - temp[1] = miny + archeight; - break; - case 4: - temp[0] = maxx; - temp[1] = maxy - archeight; - break; - case 5: - temp[0] = maxx - arcwidth; - temp[1] = maxy; - break; - case 6: - temp[0] = minx + arcwidth; - temp[1] = maxy; - break; - case 7: - temp[0] = minx; - temp[1] = maxy - archeight; - break; - } - } - - public void next() - { - if (current >= 8) - ++current; - else if (corner != null) - { - // We're iterating through the corner. Work on the child - // iterator; if it finishes, reset and move to the next - // point along the rectangle. - corner.next(); - if (corner.isDone()) - { - corner = null; - ++current; - } - } - else - { - // Make an arc between this point on the rectangle and - // the next one, and then iterate over this arc. - getPoint(current); - double x1 = temp[0]; - double y1 = temp[1]; - getPoint(current + 1); - arc.setFrameFromDiagonal(x1, y1, temp[0], temp[1]); - arc.setAngles(x1, y1, temp[0], temp[1]); - corner = arc.getPathIterator(at); - } - } - - public int currentSegment(float[] coords) - { - if (corner != null) - { - int r = corner.currentSegment(coords); - if (r == SEG_MOVETO) - r = SEG_LINETO; - return r; - } - - if (current < 9) - { - getPoint(current); - coords[0] = (float) temp[0]; - coords[1] = (float) temp[1]; - } - else if (current == 9) - return SEG_CLOSE; - else - throw new NoSuchElementException("rect iterator out of bounds"); - - if (at != null) - at.transform(coords, 0, coords, 0, 1); - return current == 0 ? SEG_MOVETO : SEG_LINETO; - } - - public int currentSegment(double[] coords) - { - if (corner != null) - { - int r = corner.currentSegment(coords); - if (r == SEG_MOVETO) - r = SEG_LINETO; - return r; - } - - if (current < 9) - { - getPoint(current); - coords[0] = temp[0]; - coords[1] = temp[1]; - } - else if (current == 9) - return SEG_CLOSE; - else - throw new NoSuchElementException("rect iterator out of bounds"); - - if (at != null) - at.transform(coords, 0, coords, 0, 1); - return current == 0 ? SEG_MOVETO : SEG_LINETO; - } - }; + /** We iterate counterclockwise around the rectangle, starting in the + * upper right. This variable tracks our current point, which + * can be on either side of a given corner. */ + private int current = 0; + + /** Child path iterator, used for corners. */ + private PathIterator corner; + + /** This is used when rendering the corners. We re-use the arc + * for each corner. */ + private Arc2D arc = new Arc2D.Double(); + + /** Temporary array used by getPoint. */ + private double[] temp = new double[2]; + + public int getWindingRule() + { + return WIND_NON_ZERO; + } + + public boolean isDone() + { + return current > 9; + } + + private void getPoint(int val) + { + switch (val) + { + case 0: + case 8: + temp[0] = maxx; + temp[1] = miny + archeight; + break; + case 7: + temp[0] = maxx; + temp[1] = maxy - archeight; + break; + case 6: + temp[0] = maxx - arcwidth; + temp[1] = maxy; + break; + case 5: + temp[0] = minx + arcwidth; + temp[1] = maxy; + break; + case 4: + temp[0] = minx; + temp[1] = maxy - archeight; + break; + case 3: + temp[0] = minx; + temp[1] = miny + archeight; + break; + case 2: + temp[0] = minx + arcwidth; + temp[1] = miny; + break; + case 1: + temp[0] = maxx - arcwidth; + temp[1] = miny; + break; + } + } + + public void next() + { + if (current >= 8) + ++current; + else if (corner != null) + { + // We're iterating through the corner. Work on the child + // iterator; if it finishes, reset and move to the next + // point along the rectangle. + corner.next(); + if (corner.isDone()) + { + corner = null; + ++current; + } + } + else + { + // Make an arc between this point on the rectangle and + // the next one, and then iterate over this arc. + getPoint(current); + double x1 = temp[0]; + double y1 = temp[1]; + getPoint(current + 1); + Rectangle2D.Double r = new Rectangle2D.Double(Math.min(x1, + temp[0]), + Math.min(y1, + temp[1]), + Math.abs(x1 + - temp[0]), + Math.abs(y1 + - temp[1])); + arc.setArc(r, (current >> 1) * 90.0, 90.0, Arc2D.OPEN); + corner = arc.getPathIterator(at); + } + } + + public int currentSegment(float[] coords) + { + if (corner != null) + { + int r = corner.currentSegment(coords); + if (r == SEG_MOVETO) + r = SEG_LINETO; + return r; + } + + if (current < 9) + { + getPoint(current); + coords[0] = (float) temp[0]; + coords[1] = (float) temp[1]; + } + else if (current == 9) + return SEG_CLOSE; + else + throw new NoSuchElementException("rect iterator out of bounds"); + + if (at != null) + at.transform(coords, 0, coords, 0, 1); + return current == 0 ? SEG_MOVETO : SEG_LINETO; + } + + public int currentSegment(double[] coords) + { + if (corner != null) + { + int r = corner.currentSegment(coords); + if (r == SEG_MOVETO) + r = SEG_LINETO; + return r; + } + + if (current < 9) + { + getPoint(current); + coords[0] = temp[0]; + coords[1] = temp[1]; + } + else if (current == 9) + return SEG_CLOSE; + else + throw new NoSuchElementException("rect iterator out of bounds"); + + if (at != null) + at.transform(coords, 0, coords, 0, 1); + return current == 0 ? SEG_MOVETO : SEG_LINETO; + } + }; } /** Return true if the given rectangle intersects this shape. @@ -286,14 +297,9 @@ public abstract class RoundRectangle2D extends RectangularShape */ public boolean intersects(double x, double y, double w, double h) { - // Here we can use the same code we use for an ordinary rectangle. - double mx = getX(); - double mw = getWidth(); - if (x < mx || x >= mx + mw || x + w < mx || x + w >= mx + mw) - return false; - double my = getY(); - double mh = getHeight(); - return y >= my && y < my + mh && y + h >= my && y + h < my + mh; + // Check if any corner is within the rectangle + return (contains(x, y) || contains(x, y + h) || contains(x + w, y + h) + || contains(x + w, y)); } /** Set the boundary of this round rectangle. @@ -315,7 +321,7 @@ public abstract class RoundRectangle2D extends RectangularShape public void setRoundRect(RoundRectangle2D rr) { setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(), - rr.getArcWidth(), rr.getArcHeight()); + rr.getArcWidth(), rr.getArcHeight()); } /** A subclass of RoundRectangle which keeps its parameters as @@ -353,8 +359,8 @@ public abstract class RoundRectangle2D extends RectangularShape * @param arcWidth The arc width * @param arcHeight The arc height */ - public Double(double x, double y, double w, double h, - double arcWidth, double arcHeight) + public Double(double x, double y, double w, double h, double arcWidth, + double arcHeight) { this.x = x; this.y = y; @@ -405,7 +411,7 @@ public abstract class RoundRectangle2D extends RectangularShape } public void setRoundRect(double x, double y, double w, double h, - double arcWidth, double arcHeight) + double arcWidth, double arcHeight) { this.x = x; this.y = y; @@ -451,8 +457,8 @@ public abstract class RoundRectangle2D extends RectangularShape * @param arcWidth The arc width * @param arcHeight The arc height */ - public Float(float x, float y, float w, float h, - float arcWidth, float arcHeight) + public Float(float x, float y, float w, float h, float arcWidth, + float arcHeight) { this.x = x; this.y = y; @@ -503,7 +509,7 @@ public abstract class RoundRectangle2D extends RectangularShape } public void setRoundRect(float x, float y, float w, float h, - float arcWidth, float arcHeight) + float arcWidth, float arcHeight) { this.x = x; this.y = y; @@ -514,7 +520,7 @@ public abstract class RoundRectangle2D extends RectangularShape } public void setRoundRect(double x, double y, double w, double h, - double arcWidth, double arcHeight) + double arcWidth, double arcHeight) { this.x = (float) x; this.y = (float) y; diff --git a/libjava/java/awt/image/DirectColorModel.java b/libjava/java/awt/image/DirectColorModel.java index 9444e831f83..3ac43cf25b6 100644 --- a/libjava/java/awt/image/DirectColorModel.java +++ b/libjava/java/awt/image/DirectColorModel.java @@ -60,7 +60,6 @@ public class DirectColorModel extends PackedColorModel * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel * @param bmask the bits describing the blue component of a pixel - * @param amask the bits describing the alpha component of a pixel */ public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask) { @@ -82,6 +81,7 @@ public class DirectColorModel extends PackedColorModel * @param rmask the bits describing the red component of a pixel * @param gmask the bits describing the green component of a pixel * @param bmask the bits describing the blue component of a pixel + * @param amask the bits describing the alpha component of a pixel */ public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask, int amask) diff --git a/libjava/java/awt/image/Kernel.java b/libjava/java/awt/image/Kernel.java index 27d6ddd8fae..4898f9ed82b 100644 --- a/libjava/java/awt/image/Kernel.java +++ b/libjava/java/awt/image/Kernel.java @@ -117,7 +117,7 @@ public class Kernel implements Cloneable throws IllegalArgumentException { if (data == null) - return (float[])this.data.clone(); + return (float[])this.data.clone(); if (data.length < this.data.length) throw new IllegalArgumentException(); @@ -131,6 +131,13 @@ public class Kernel implements Cloneable */ public Object clone() { - return new Kernel(width, height, data); + try + { + return super.clone(); + } + catch (CloneNotSupportedException e) + { + throw (Error) new InternalError().initCause(e); // Impossible + } } } diff --git a/libjava/java/awt/peer/MenuBarPeer.java b/libjava/java/awt/peer/MenuBarPeer.java index 38f57ecdbb4..6018c41b363 100644 --- a/libjava/java/awt/peer/MenuBarPeer.java +++ b/libjava/java/awt/peer/MenuBarPeer.java @@ -43,7 +43,6 @@ import java.awt.Menu; public interface MenuBarPeer extends MenuComponentPeer { void addHelpMenu(Menu menu); - void addMenu(Menu menu); void delMenu(int index); } // interface MenuBarPeer diff --git a/libjava/javax/swing/AbstractButton.java b/libjava/javax/swing/AbstractButton.java index 3c2a4cdea7b..11ab1983ec6 100644 --- a/libjava/javax/swing/AbstractButton.java +++ b/libjava/javax/swing/AbstractButton.java @@ -51,7 +51,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.util.EventListener; import javax.accessibility.AccessibleAction; import javax.accessibility.AccessibleIcon; @@ -214,24 +213,28 @@ public abstract class AbstractButton extends JComponent Action action; /** The button's current state. */ - ButtonModel model; + protected ButtonModel model; /** The margin between the button's border and its label. */ Insets margin; - /** a hint to the look and feel class, suggesting which character in the + /** A hint to the look and feel class, suggesting which character in the * button's label should be underlined when drawing the label. */ int mnemonicIndex; /** Listener the button uses to receive ActionEvents from its model. */ - ActionListener actionListener; + protected ActionListener actionListener; /** Listener the button uses to receive ItemEvents from its model. */ - ItemListener itemListener; + protected ItemListener itemListener; /** Listener the button uses to receive ChangeEvents from its model. */ - ChangeListener changeListener; + protected ChangeListener changeListener; + /** The time in miliseconds in which clicks get coalesced into a single + * ActionEvent. */ + long multiClickThreshhold; + /** Listener the button uses to receive PropertyChangeEvents from its Action. */ PropertyChangeListener actionPropertyChangeListener; @@ -296,9 +299,9 @@ public abstract class AbstractButton extends JComponent /** Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes. */ public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition"; - /** + /** * A Java Accessibility extension of the AbstractButton. - */ + */ protected abstract class AccessibleAbstractButton extends AccessibleJComponent implements AccessibleAction, AccessibleValue, AccessibleText @@ -430,7 +433,7 @@ public abstract class AbstractButton extends JComponent } public String getSelectedText() - { + { return null; // TODO } @@ -440,33 +443,6 @@ public abstract class AbstractButton extends JComponent } } - /** - * Helper class used to subscribe to FocusEvents received by the button. - */ - private class ButtonFocusListener implements FocusListener - { - /** - * Possibly repaint the model in response to loss of focus. - * - * @param event The loss-of-focus event - */ - public void focusLost(FocusEvent event) - { - if (AbstractButton.this.isFocusPainted()) - AbstractButton.this.repaint(); - } - - /** - * Possibly repaint the button in response to acquisition of focus. - * - * @param event The gained-focus event - */ - public void focusGained(FocusEvent event) - { - if (AbstractButton.this.isFocusPainted()) - AbstractButton.this.repaint(); - } - } /** * Creates a new AbstractButton object. @@ -549,12 +525,12 @@ public abstract class AbstractButton extends JComponent borderPainted = true; contentAreaFilled = true; - iconTextGap = 4; + focusPainted = true; + setFocusable(true); setAlignmentX(LEFT_ALIGNMENT); setAlignmentY(CENTER_ALIGNMENT); - addFocusListener(new ButtonFocusListener()); setDisplayedMnemonicIndex(-1); } @@ -601,6 +577,18 @@ public abstract class AbstractButton extends JComponent listenerList.remove(ActionListener.class, l); } + /** + * Returns all added ActionListener objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public ActionListener[] getActionListeners() + { + return (ActionListener[]) listenerList.getListeners(ActionListener.class); + } + /** * Adds an ItemListener to the button's listener list. When the button's * model changes state (between any of ARMED, ENABLED, PRESSED, ROLLOVER @@ -624,6 +612,18 @@ public abstract class AbstractButton extends JComponent listenerList.remove(ItemListener.class, l); } + /** + * Returns all added ItemListener objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public ItemListener[] getItemListeners() + { + return (ItemListener[]) listenerList.getListeners(ItemListener.class); + } + /** * Adds a ChangeListener to the button's listener list. When the button's * model changes any of its (non-bound) properties, these listeners will be @@ -646,6 +646,18 @@ public abstract class AbstractButton extends JComponent listenerList.remove(ChangeListener.class, l); } + /** + * Returns all added ChangeListener objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public ChangeListener[] getChangeListeners() + { + return (ChangeListener[]) listenerList.getListeners(ChangeListener.class); + } + /** * Calls {@link ItemListener.itemStateChanged} on each ItemListener in * the button's listener list. @@ -655,9 +667,10 @@ public abstract class AbstractButton extends JComponent public void fireItemStateChanged(ItemEvent e) { e.setSource(this); - EventListener[] ll = listenerList.getListeners(ItemListener.class); - for (int i = 0; i < ll.length; i++) - ((ItemListener)ll[i]).itemStateChanged(e); + ItemListener[] listeners = getItemListeners(); + + for (int i = 0; i < listeners.length; i++) + listeners[i].itemStateChanged(e); } /** @@ -669,9 +682,10 @@ public abstract class AbstractButton extends JComponent public void fireActionPerformed(ActionEvent e) { e.setSource(this); - EventListener[] ll = listenerList.getListeners(ActionListener.class); - for (int i = 0; i < ll.length; i++) - ((ActionListener)ll[i]).actionPerformed(e); + ActionListener[] listeners = getActionListeners(); + + for (int i = 0; i < listeners.length; i++) + listeners[i].actionPerformed(e); } /** @@ -683,9 +697,10 @@ public abstract class AbstractButton extends JComponent */ public void fireStateChanged(ChangeEvent e) { - EventListener[] ll = listenerList.getListeners(ChangeListener.class); - for (int i = 0; i < ll.length; i++) - ((ChangeListener)ll[i]).stateChanged(changeEvent); + ChangeListener[] listeners = getChangeListeners(); + + for (int i = 0; i < listeners.length; i++) + listeners[i].stateChanged(changeEvent); } /** @@ -1879,4 +1894,33 @@ public abstract class AbstractButton extends JComponent public void updateUI() { } + + /** + * Returns the current time in milliseconds in which clicks gets coalesced + * into a single ActionEvent. + * + * @return the time in milliseconds + * + * @since 1.4 + */ + public long getMultiClickThreshhold() + { + return multiClickThreshhold; + } + + /** + * Sets the time in milliseconds in which clicks gets coalesced into a single + * ActionEvent. + * + * @param threshhold the time in milliseconds + * + * @since 1.4 + */ + public void setMultiClickThreshhold(long threshhold) + { + if (threshhold < 0) + throw new IllegalArgumentException(); + + multiClickThreshhold = threshhold; + } } diff --git a/libjava/javax/swing/ActionMap.java b/libjava/javax/swing/ActionMap.java index 2a5c67aa4d3..98615914683 100644 --- a/libjava/javax/swing/ActionMap.java +++ b/libjava/javax/swing/ActionMap.java @@ -86,8 +86,8 @@ public class ActionMap { Object result = actionMap.get(key); - if (result == null) - result = parent.get(key); + if (result == null && parent != null) + result = parent.get(key); return (Action) result; } diff --git a/libjava/javax/swing/Box.java b/libjava/javax/swing/Box.java index 4e338747859..26588a56457 100644 --- a/libjava/javax/swing/Box.java +++ b/libjava/javax/swing/Box.java @@ -47,7 +47,11 @@ import java.awt.Dimension; import java.awt.AWTError; /** - * Needs some work I guess.... + * A component that uses a {@link BoxLayout} as Layout Manager. + * + * In addition to that, this class provides a set of static methods for + * creating some filler components ('struts' and 'glue') for use in + * containers that are laid out using BoxLayout. * * @author Ronald Veldema (rveldema@cs.vu.nl) */ @@ -69,7 +73,10 @@ public class Box extends JComponent implements Accessible return null; } } - + + /** + * A component that servers as a filler in BoxLayout controlled containers. + */ public static class Filler extends JComponent implements Accessible { private static final long serialVersionUID = -1204263191910183998L; @@ -93,11 +100,25 @@ public class Box extends JComponent implements Accessible private transient Dimension min, pref, max; + /** + * Creates a new instance of Filler. + * + * @param min the minimum size of the filler. + * @param pref the preferred size of the filler. + * @param max the maximum size of the filler. + */ public Filler(Dimension min, Dimension pref, Dimension max) { changeShape(min, pref, max); } + /** + * Changes the dimensions of this Filler. + * + * @param min the new minimum size of the filler. + * @param pref the new preferred size of the filler. + * @param max the new maximum size of the filler. + */ public void changeShape(Dimension min, Dimension pref, Dimension max) { this.min = min; @@ -113,65 +134,137 @@ public class Box extends JComponent implements Accessible return accessibleContext; } + /** + * Returns the maximum size of this Filler. + * + * @return the maximum size of this Filler. + */ public Dimension getMaximumSize() { return max; } + /** + * Returns the minimum size of this Filler. + * + * @return the minimum size of this Filler. + */ public Dimension getMinimumSize() { return min; } + /** + * Returns the preferred size of this Filler. + * + * @return the preferred size of this Filler. + */ public Dimension getPreferredSize() { return pref; } } + /** + * Creates a new Box component, that lays out its children according + * to the axis parameter. + * + * @param axis the orientation of the BoxLayout. + * + * @see BoxLayout#X_AXIS + * @see BoxLayout#Y_AXIS + * @see BoxLayout#LINE_AXIS + * @see BoxLayout#PAGE_AXIS + */ public Box(int axis) { - setLayout(new BoxLayout(this, axis)); + super.setLayout(new BoxLayout(this, axis)); } + /** + * Creates a filler component which acts as glue between components. + * It does not take space unless some extra space is available. If extra + * space is available, this component can expand in both X and Y directions. + * + * @return a glue-like filler component. + */ public static Component createGlue() { - return null; + Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0), + new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE) + ); + return glue; } public static Box createHorizontalBox() { - return null; + return new Box(BoxLayout.X_AXIS); } + /** + * Creates a filler component which acts as glue between components. + * It does not take space unless some extra space is available. If extra + * space is available, this component can expand in the X direction. + * + * @return a glue-like filler component. + */ public static Component createHorizontalGlue() { - return null; + return createGlue(); } + /** + * Creates a filler component which acts as strut between components. + * It will fill exactly the specified horizontal size. + * + * @param width the width of this strut in pixels. + * + * @return a strut-like filler component. + */ public static Component createHorizontalStrut(int width) { - return null; + Filler strut = new Filler(new Dimension(width, 0), + new Dimension(width, 0), + new Dimension(width, Integer.MAX_VALUE)); + return strut; } public static Component createRigidArea(Dimension d) { - return null; + return new Filler(d, d, d); } public static Box createVerticalBox() { - return null; + return new Box(BoxLayout.Y_AXIS); } + /** + * Creates a filler component which acts as glue between components. + * It does not take space unless some extra space is available. If extra + * space is available, this component can expand in the Y direction. + * + * @return a glue-like filler component. + */ public static Component createVerticalGlue() { - return null; + return createGlue(); } + /** + * Creates a filler component which acts as strut between components. + * It will fill exactly the specified vertical size. + * + * @param height the height of this strut in pixels. + * + * @return a strut-like filler component. + */ public static Component createVerticalStrut(int height) { - return null; + Filler strut = new Filler(new Dimension(0, height), + new Dimension(0, height), + new Dimension(Integer.MAX_VALUE, height)); + return strut; } public void setLayout(LayoutManager l) diff --git a/libjava/javax/swing/BoxLayout.java b/libjava/javax/swing/BoxLayout.java index 0dd97ac60ba..7b12602a9ff 100644 --- a/libjava/javax/swing/BoxLayout.java +++ b/libjava/javax/swing/BoxLayout.java @@ -42,15 +42,11 @@ import java.awt.Component; import java.awt.ComponentOrientation; import java.awt.Container; import java.awt.Dimension; -import java.awt.GridLayout; import java.awt.LayoutManager2; import java.io.Serializable; - /** * A layout for swing components. - * This implementation delegates its methods to - * java.awt.GridLayout to do its work. * * @author Ronald Veldema (rveldema@cs.vu.nl) */ @@ -86,11 +82,6 @@ public class BoxLayout implements LayoutManager2, Serializable */ private Container container; - /* - * Internal layout. - */ - private GridLayout grid; - /* * Current type of component layouting. Defaults to X_AXIS. */ @@ -108,75 +99,41 @@ public class BoxLayout implements LayoutManager2, Serializable { int width = 0; int height = 0; - ComponentOrientation orientation = container.getComponentOrientation(); - this.container = container; this.way = way; - - switch (way) - { - case X_AXIS: - width = 1; - break; - case Y_AXIS: - height = 1; - break; - case LINE_AXIS: - if (orientation.isHorizontal()) - height = 1; - else - width = 1; - break; - case PAGE_AXIS: - if (!orientation.isHorizontal()) - height = 1; - else - width = 1; - break; - default: - throw new AWTError("Invalid value for way"); - } - - grid = new GridLayout(width, height); } /** - * Adds a component to the layout. + * Adds a component to the layout. Not used in BoxLayout. * * @param name The name of the component to add. * @param component the component to add to the layout. */ public void addLayoutComponent(String name, Component component) { - if (way == X_AXIS - || (way == LINE_AXIS - && component.getComponentOrientation().isHorizontal()) - || (way == PAGE_AXIS - && !component.getComponentOrientation().isHorizontal())) - grid.setColumns(grid.getColumns() + 1); - else - grid.setRows(grid.getRows() + 1); } /** - * Removes a component from the layout. + * Removes a component from the layout. Not used in BoxLayout. * * @param component The component to remove from the layout. */ public void removeLayoutComponent(Component component) { - grid.removeLayoutComponent(component); - - if (way == X_AXIS - || (way == LINE_AXIS - && component.getComponentOrientation().isHorizontal()) - || (way == PAGE_AXIS - && !component.getComponentOrientation().isHorizontal())) - grid.setColumns(grid.getColumns() - 1); - else - grid.setRows(grid.getRows() - 1); } + private boolean isHorizontalIn(Container parent) + { + ComponentOrientation orientation = parent.getComponentOrientation(); + return this.way == X_AXIS + || (this.way == LINE_AXIS + && orientation.isHorizontal()) + || (this.way == PAGE_AXIS + && (!orientation.isHorizontal())); + } + + + /** * Returns the preferred size of the layout. * @@ -188,8 +145,38 @@ public class BoxLayout implements LayoutManager2, Serializable { if (parent != container) throw new AWTError("invalid parent"); + + int x = 0; + int y = 0; + + Component[] children = parent.getComponents(); + + if (isHorizontalIn(parent)) + { + // sum up preferred widths of components, find maximum of preferred + // heights + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getPreferredSize(); + x += sz.width; + y = Math.max(y, sz.height); + } + } + else + { + // sum up preferred heights of components, find maximum of + // preferred widths + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getPreferredSize(); + y += sz.height; + x = Math.max(x, sz.width); + } + } - return grid.preferredLayoutSize(parent); + return new Dimension(x, y); } /** @@ -203,8 +190,38 @@ public class BoxLayout implements LayoutManager2, Serializable { if (parent != container) throw new AWTError("invalid parent"); + + int x = 0; + int y = 0; + + Component[] children = parent.getComponents(); + + if (isHorizontalIn(parent)) + { + // sum up preferred widths of components, find maximum of preferred + // heights + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getMinimumSize(); + x += sz.width; + y = Math.max(y, sz.height); + } + } + else + { + // sum up preferred heights of components, find maximum of + // preferred widths + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getMinimumSize(); + y += sz.height; + x = Math.max(x, sz.width); + } + } - return grid.minimumLayoutSize(parent); + return new Dimension(x, y); } /** @@ -216,19 +233,69 @@ public class BoxLayout implements LayoutManager2, Serializable { if (parent != container) throw new AWTError("invalid parent"); - - grid.layoutContainer(parent); - } + Dimension size = parent.getSize(); + + Component[] children = parent.getComponents(); + + if (isHorizontalIn(parent)) + { + int x = 0; + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getPreferredSize(); + int width = sz.width; + int height = sz.height; + int cy = 0; + if (height > size.height) + { + height = size.height; + } + else + { + cy = (int) ((size.height - height) * comp.getAlignmentY()); + } + + comp.setSize(width, height); + comp.setLocation(x, cy); + x = x + width; + } + } + else + { + int y = 0; + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getPreferredSize(); + int width = sz.width; + int height = sz.height; + int cx = 0; + if (width > size.width) + { + width = size.width; + } + else + { + cx = (int) ((size.width - width) * comp.getAlignmentX()); + } + + comp.setSize(width, height); + comp.setLocation(cx, y); + y = y + height; + } + } + } + /** - * Adds a component to the layout. + * Adds a component to the layout. Not used in BoxLayout * * @param child The component to add to the layout. * @param constraints The constraints for the component in the layout. */ public void addLayoutComponent(Component child, Object constraints) { - addLayoutComponent("", child); } /** @@ -284,7 +351,37 @@ public class BoxLayout implements LayoutManager2, Serializable { if (parent != container) throw new AWTError("invalid parent"); - - return preferredLayoutSize(parent); + + int x = 0; + int y = 0; + + Component[] children = parent.getComponents(); + + if (isHorizontalIn(parent)) + { + + // sum up preferred widths of components, find maximum of preferred + // heights + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getMaximumSize(); + x += sz.width; + y = Math.max(y, sz.height); + } + } + else + { + // sum up preferred heights of components, find maximum of + // preferred widths + for (int index = 0; index < children.length; index++) + { + Component comp = children[index]; + Dimension sz = comp.getMaximumSize(); + y += sz.height; + x = Math.max(x, sz.width); + } + } + return new Dimension(x, y); } } diff --git a/libjava/javax/swing/ButtonGroup.java b/libjava/javax/swing/ButtonGroup.java index 8202fa6cb82..5f6a28d86e8 100644 --- a/libjava/javax/swing/ButtonGroup.java +++ b/libjava/javax/swing/ButtonGroup.java @@ -42,19 +42,18 @@ import java.util.Enumeration; import java.util.Vector; -public class ButtonGroup - implements Serializable +/** + * DOCUMENT ME! + */ +public class ButtonGroup implements Serializable { + /** DOCUMENT ME! */ private static final long serialVersionUID = 4259076101881721375L; - /** - * The buttons added to this button group. - */ + /** The buttons added to this button group. */ protected Vector buttons = new Vector(); - /** - * The currently selected button model. - */ + /** The currently selected button model. */ ButtonModel sel; /** @@ -99,17 +98,24 @@ public class ButtonGroup /** * Returns the currently selected button model. * - * @return the currently selected button model, - * null if none was selected yet + * @return the currently selected button model, null if none was selected + * yet */ public ButtonModel getSelection() { return sel; } + /** + * DOCUMENT ME! + * + * @param m DOCUMENT ME! + * + * @return DOCUMENT ME! + */ AbstractButton FindButton(ButtonModel m) { - for (int i = 0;i < buttons.size(); i++) + for (int i = 0; i < buttons.size(); i++) { AbstractButton a = (AbstractButton) buttons.get(i); if (a.getModel() == m) @@ -119,46 +125,40 @@ public class ButtonGroup } /** - * Sets the currently selected button model. Only one button of a group - * can be selected at a time. + * Sets the currently selected button model. Only one button of a group can + * be selected at a time. * * @param m the model to select * @param b true if this button is to be selected, false otherwise */ public void setSelected(ButtonModel m, boolean b) { - if ((m == sel) && (b == true)) - { - // clicked on same item twice. - System.out.println("PRESSED TWICE:" + m + ", sel=" + sel); - return; - } + if ((sel != m || b) && (! b || sel == m)) + return; - if (sel != null) + if (b && sel != m) { - System.out.println("DESELECTING: " + sel); - sel.setSelected(! b); - - AbstractButton but = FindButton(sel); - if (but != null) - { - System.out.println("REPAINT-REQUEST: " + but.text); - //but.revalidate(); - but.repaint(); - } + ButtonModel old = sel; + sel = m; + + if (old != null) + old.setSelected(false); + AbstractButton button = FindButton(old); + if (button != null) + button.repaint(); } - else - System.out.println("NO SELECTION YET"); - - sel = m; + else if (! b && sel == m) + m.setSelected(true); } /** - * Checks if the given ButtonModel is selected - * in this button group. + * Checks if the given ButtonModel is selected in this button + * group. + * + * @param m DOCUMENT ME! * - * @return true of given ButtonModel is selected, - * false otherwise + * @return true of given ButtonModel is selected, false + * otherwise */ public boolean isSelected(ButtonModel m) { diff --git a/libjava/javax/swing/ComboBoxEditor.java b/libjava/javax/swing/ComboBoxEditor.java index 8559217b6b4..30813175a52 100644 --- a/libjava/javax/swing/ComboBoxEditor.java +++ b/libjava/javax/swing/ComboBoxEditor.java @@ -42,49 +42,56 @@ import java.awt.event.ActionListener; /** * ComboBoxEditor - * @author Andrew Selkirk - * @version 1.0 + * + * @author Andrew Selkirk + * @author Olga Rodimina + * @version 1.0 */ -public interface ComboBoxEditor { - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getEditorComponent - * @returns Component - */ - Component getEditorComponent(); - - /** - * setItem - * @param item TODO - */ - void setItem(Object item); - - /** - * getItem - * @returns Object - */ - Object getItem(); - - /** - * selectAll - */ - void selectAll(); - - /** - * addActionListener - * @param listener TODO - */ - void addActionListener(ActionListener listener); - - /** - * removeActionListener - * @param listener TODO - */ - void removeActionListener(ActionListener listener); - - +public interface ComboBoxEditor +{ + /** + * This method returns component that will be used by the combo box to + * display/edit currently selected item in the combo box. + * + * @return Component that will be used by the combo box to display/edit + * currently selected item + */ + Component getEditorComponent(); + + /** + * Sets item that should be editted when any editting operation is performed + * by the user. The value is always equal to the currently selected value + * in the combo box. Thus, whenever a different value is selected from the + * combo box list then this method should be called to change editting item + * to the new selected item. + * + * @param selectedItem item that is currently selected in the combo box + */ + void setItem(Object item); + + /** + * This method returns item that is currently editable. + * + * @return Item in the combo box that is currently editable + */ + Object getItem(); + + /** + * selectAll + */ + void selectAll(); + + /** + * This method adds specified ActionListener to this ComboBoxEditor. + * + * @param listener + */ + void addActionListener(ActionListener listener); + + /** + * This method removes given ActionListener from this ComboBoxEditor. + * + * @param listener TODO + */ + void removeActionListener(ActionListener listener); } // ComboBoxEditor diff --git a/libjava/javax/swing/ComboBoxModel.java b/libjava/javax/swing/ComboBoxModel.java index b3b2112b582..c3b59bda630 100644 --- a/libjava/javax/swing/ComboBoxModel.java +++ b/libjava/javax/swing/ComboBoxModel.java @@ -37,28 +37,32 @@ exception statement from your version. */ package javax.swing; + /** - * ComboBoxModel - * @author Andrew Selkirk - * @version 1.0 + * ComboBoxModel is a data model for JComboBox. This model keeps + * track of elements contained in the JComboBox as well as the current + * combo box selection. Whenever selection in the JComboBox changes, the + * ComboBoxModel should fire ListDataEvents to ComboBox's ListDataListeners. + * + * @author Andrew Selkirk + * @version 1.0 */ -public interface ComboBoxModel extends ListModel { - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * setSelectedItem - * @param item TODO - */ - void setSelectedItem(Object item); - - /** - * getSelectedItem - * @returns Object - */ - Object getSelectedItem(); - +public interface ComboBoxModel extends ListModel +{ + /** + * This method sets the selected item in the combo box. Class + * implementing this interface should fire ListDataEvents to + * all registered ListDataListeners to indicated that the + * selection has changed. + * + * @param item item in the combo box that should be selected + */ + void setSelectedItem(Object item); + /** + * The method returns currently selected item in the combo box + * + * @returns item that is currently selected in the combo box. + */ + Object getSelectedItem(); } // ComboBoxModel diff --git a/libjava/javax/swing/DefaultButtonModel.java b/libjava/javax/swing/DefaultButtonModel.java index e9a1356e8a6..4c7c24772f9 100644 --- a/libjava/javax/swing/DefaultButtonModel.java +++ b/libjava/javax/swing/DefaultButtonModel.java @@ -1,4 +1,4 @@ -/* DefaultButtonModel.java -- +/* DefaultButtonModel.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,87 +44,103 @@ import java.awt.event.ItemListener; import java.awt.event.KeyEvent; import java.io.Serializable; import java.util.EventListener; - import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; + /** * The purpose of this class is to model the dynamic state of an abstract * button. The concrete button type holding this state may be a a "toggle" * button (checkbox, radio button) or a "push" button (menu button, button). - * - * If the model is disabled, only the "selected" property can be changed. - * An attempt to change the "armed", "rollover" or "pressed" properties - * while the model is disabled will be blocked. - * - * Any successful (non-blocked) change to the model's properties will - * trigger the firing of a ChangeEvent. - * - * Any change to the "selected" property will trigger the firing of an - * ItemEvent in addition to ChangeEvent. This is true whether the model is - * enabled or not. - * - * One other state change is special: the transition from "enabled, armed - * and pressd" to "enabled, armed and not-pressed". This is considered the - * "trailing edge" of a successful mouse click, and therefore fires an - * ActionEvent in addition to a ChangeEvent. + * If the model is disabled, only the "selected" property can be changed. An + * attempt to change the "armed", "rollover" or "pressed" properties while + * the model is disabled will be blocked. Any successful (non-blocked) change + * to the model's properties will trigger the firing of a ChangeEvent. Any + * change to the "selected" property will trigger the firing of an ItemEvent + * in addition to ChangeEvent. This is true whether the model is enabled or + * not. One other state change is special: the transition from "enabled, + * armed and pressd" to "enabled, armed and not-pressed". This is considered + * the "trailing edge" of a successful mouse click, and therefore fires an + * ActionEvent in addition to a ChangeEvent. In all other respects this class + * is just a container of boolean flags. * - * In all other respects this class is just a container of boolean flags. - * - * @author Graydon Hoare (graydon@redhat.com) + * @author Graydon Hoare (graydon_at_redhat.com) */ public class DefaultButtonModel implements ButtonModel, Serializable { + /** DOCUMENT ME! */ static final long serialVersionUID = -5342609566534980231L; - /** Indicates that the button is partially committed to being - pressed, but not entirely. This usually happens when a user has pressed - but not yet released the mouse button. */ + /** + * Indicates that the button is partially committed to being + * pressed, but not entirely. This usually happens when a user has pressed + * but not yet released the mouse button. + */ public static final int ARMED = 1; - /** State constant indicating that the button is enabled. Buttons cannot - be pressed or selected unless they are enabled. */ + /** + * State constant indicating that the button is enabled. Buttons cannot be + * pressed or selected unless they are enabled. + */ public static final int ENABLED = 8; - /** State constant indicating that the user is holding down the button. - When this transitions from true to false, an ActionEvent may be fired, - depending on the value of the "armed" property.*/ + /** + * State constant indicating that the user is holding down the button. When + * this transitions from true to false, an ActionEvent may be fired, + * depending on the value of the "armed" property. + */ public static final int PRESSED = 4; - /** State constant indicating that the mouse is currently positioned over - the button. */ + /** + * State constant indicating that the mouse is currently positioned over the + * button. + */ public static final int ROLLOVER = 16; - /** State constant indicating that the button is selected. This constant - is only meaningful for toggle-type buttons (radio buttons, - checkboxes). */ + /** + * State constant indicating that the button is selected. This constant is + * only meaningful for toggle-type buttons (radio buttons, checkboxes). + */ public static final int SELECTED = 2; - /** Represents the "state properties" (armed, enabled, pressed, rollover - and selected) by a bitwise combination of integer constants. */ + /** + * Represents the "state properties" (armed, enabled, pressed, rollover and + * selected) by a bitwise combination of integer constants. + */ protected int stateMask = ENABLED; - /** List of ItemListeners, ChangeListeners, and ActionListeners - registered on this model. */ - protected EventListenerList listenerList = new EventListenerList();; + /** + * List of ItemListeners, ChangeListeners, and ActionListeners registered on + * this model. + */ + protected EventListenerList listenerList = new EventListenerList(); + ; - /** The single ChangeEvent this model (re)uses to call its - ChangeListeners. */ + /** The single ChangeEvent this model (re)uses to call its ChangeListeners. */ protected ChangeEvent changeEvent = new ChangeEvent(this); - /** The group this model belongs to. Only one button in a group may be - selected at any given time. */ + /** + * The group this model belongs to. Only one button in a group may be + * selected at any given time. + */ protected ButtonGroup group; - - /** The key code (one of {@link java.awt.event.KeyEvent} VK_*) used to - press this button via a keyboard interface. */ + + /** + * The key code (one of {@link java.awt.event.KeyEvent} VK_) used to press + * this button via a keyboard interface. + */ protected int mnemonic = KeyEvent.VK_UNDEFINED; - /** The string used as the "command" property of any ActionEvent this - model sends. */ + /** + * The string used as the "command" property of any ActionEvent this model + * sends. + */ protected String actionCommand; + /** + * Creates a new DefaultButtonModel object. + */ public DefaultButtonModel() { } @@ -135,10 +151,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable * * @return null */ - public Object[] getSelectedObjects() - { - return null; - } + public Object[] getSelectedObjects() + { + return null; + } /** * Returns a specified class of listeners. @@ -151,10 +167,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable { return listenerList.getListeners(listenerType); } - + /** - * Add an ActionListener to the model. Usually only called to subscribe - * an AbstractButton's listener to the model. + * Add an ActionListener to the model. Usually only called to subscribe an + * AbstractButton's listener to the model. * * @param l The listener to add */ @@ -162,10 +178,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable { listenerList.add(ActionListener.class, l); } - + /** - * Remove an ActionListener to the model. Usually only called to - * unsubscribe an AbstractButton's listener to the model. + * Remove an ActionListener to the model. Usually only called to unsubscribe + * an AbstractButton's listener to the model. * * @param l The listener to remove */ @@ -185,8 +201,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable } /** - * Add an ItemListener to the model. Usually only called to subscribe - * an AbstractButton's listener to the model. + * Add an ItemListener to the model. Usually only called to subscribe an + * AbstractButton's listener to the model. * * @param l The listener to add */ @@ -196,8 +212,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable } /** - * Remove an ItemListener to the model. Usually only called to - * unsubscribe an AbstractButton's listener to the model. + * Remove an ItemListener to the model. Usually only called to unsubscribe + * an AbstractButton's listener to the model. * * @param l The listener to remove */ @@ -217,8 +233,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable } /** - * Add a ChangeListener to the model. Usually only called to subscribe - * an AbstractButton's listener to the model. + * Add a ChangeListener to the model. Usually only called to subscribe an + * AbstractButton's listener to the model. * * @param l The listener to add */ @@ -228,8 +244,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable } /** - * Remove a ChangeListener to the model. Usually only called to - * unsubscribe an AbstractButton's listener to the model. + * Remove a ChangeListener to the model. Usually only called to unsubscribe + * an AbstractButton's listener to the model. * * @param l The listener to remove */ @@ -258,61 +274,60 @@ public class DefaultButtonModel implements ButtonModel, Serializable public void fireItemStateChanged(ItemEvent e) { ItemListener[] ll = getItemListeners(); - + for (int i = 0; i < ll.length; i++) ll[i].itemStateChanged(e); } /** * Inform each ActionListener in the {@link listenerList} that an - * ActionEvent has occurred. This happens in response to the any change - * to the {@link stateMask} field which makes the enabled, armed and - * pressed properties all simultaneously true. + * ActionEvent has occurred. This happens in response to the any change to + * the {@link stateMask} field which makes the enabled, armed and pressed + * properties all simultaneously true. * * @param e The ActionEvent to fire */ public void fireActionPerformed(ActionEvent e) { ActionListener[] ll = getActionListeners(); - + for (int i = 0; i < ll.length; i++) ll[i].actionPerformed(e); } /** - * Inform each ChangeListener in the {@link listenerList} that a - * ChangeEvent has occurred. This happens in response to the any change - * to a property of the model. - * - * @param event The ChangeEvent to fire + * Inform each ChangeListener in the {@link listenerList} that a ChangeEvent + * has occurred. This happens in response to the any change to a property + * of the model. */ public void fireStateChanged() { ChangeListener[] ll = getChangeListeners(); - + for (int i = 0; i < ll.length; i++) ll[i].stateChanged(changeEvent); } /** - * Helper method to fire a ChangeEvent with the model as the event's - * source. + * Helper method to fire a ChangeEvent with the model as the event's source. + * + * @param stateflag DOCUMENT ME! + * @param b DOCUMENT ME! */ protected void changeState(int stateflag, boolean b) - { + { int oldstate = stateMask; int newstate; if (b) newstate = oldstate | stateflag; else - newstate = oldstate & ~stateflag; + newstate = oldstate & ~ stateflag; if (oldstate == newstate) return; - if ((stateflag != SELECTED) - && (stateflag != ENABLED) + if ((stateflag != SELECTED) && (stateflag != ENABLED) && (stateMask & ENABLED) == 0) return; @@ -320,35 +335,38 @@ public class DefaultButtonModel implements ButtonModel, Serializable fireStateChanged(); - if ((oldstate & SELECTED) == 0 - && (newstate & SELECTED) == SELECTED) - fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, - null, ItemEvent.SELECTED)); + if ((oldstate & SELECTED) == 0 && (newstate & SELECTED) == SELECTED) + { + fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, + null, ItemEvent.SELECTED)); + if (group != null) + group.setSelected(this, true); + } - else if ((oldstate & SELECTED) == SELECTED - && (newstate & SELECTED) == 0) - fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, - null, ItemEvent.DESELECTED)); - - else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED) - && - ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0)) + else if ((oldstate & SELECTED) == SELECTED && (newstate & SELECTED) == 0) { - fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, - actionCommand)); + fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, + null, ItemEvent.DESELECTED)); + if (group != null) + group.setSelected(this, false); } - } - + + else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED) + && ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0)) + fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, + actionCommand)); + } + /** * Get the value of the model's "armed" property. - * - * @return The current "armed" property + * + * @return The current "armed" property */ public boolean isArmed() { return (stateMask & ARMED) == ARMED; } - + /** * Set the value of the model's "armed" property. * @@ -365,9 +383,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable * @return The current "enabled" property. */ public boolean isEnabled() - { + { return (stateMask & ENABLED) == ENABLED; - } + } /** * Set the value of the model's "enabled" property. @@ -385,9 +403,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable * @param p The new "pressed" property */ public void setPressed(boolean p) - { + { changeState(PRESSED, p); - } + } /** * Get the value of the model's "pressed" property. @@ -409,7 +427,6 @@ public class DefaultButtonModel implements ButtonModel, Serializable changeState(ROLLOVER, r); } - /** * Set the value of the model's "selected" property. * @@ -436,9 +453,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable * @return The current "rollover" property */ public boolean isRollover() - { + { return (stateMask & ROLLOVER) == ROLLOVER; - } + } /** * Get the value of the model's "mnemonic" property. @@ -446,7 +463,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable * @return The current "mnemonic" property */ public int getMnemonic() - { + { return mnemonic; } @@ -459,15 +476,15 @@ public class DefaultButtonModel implements ButtonModel, Serializable { if (mnemonic != key) { - mnemonic = key; - fireStateChanged(); + mnemonic = key; + fireStateChanged(); } } - + /** - * Set the value of the model's "actionCommand" property. This property - * is used as the "command" property of the {@link ActionEvent} fired - * from the model. + * Set the value of the model's "actionCommand" property. This property is + * used as the "command" property of the {@link ActionEvent} fired from the + * model. * * @param s The new "actionCommand" property. */ @@ -475,11 +492,11 @@ public class DefaultButtonModel implements ButtonModel, Serializable { if (actionCommand != s) { - actionCommand = s; - fireStateChanged(); + actionCommand = s; + fireStateChanged(); } - } - + } + /** * Returns the current value of the model's "actionCommand" property. * @@ -491,9 +508,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable } /** - * Set the value of the model's "group" property. The model is said to be - * a member of the {@link ButtonGroup} held in its "group" property, and - * only one model in a given group can have their "selected" property be + * Set the value of the model's "group" property. The model is said to be a + * member of the {@link ButtonGroup} held in its "group" property, and only + * one model in a given group can have their "selected" property be * true at a time. * * @param g The new "group" property @@ -502,8 +519,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable { if (group != g) { - group = g; - fireStateChanged(); + group = g; + fireStateChanged(); } } diff --git a/libjava/javax/swing/DefaultComboBoxModel.java b/libjava/javax/swing/DefaultComboBoxModel.java index 55faf8fdf3b..a5546f2954a 100644 --- a/libjava/javax/swing/DefaultComboBoxModel.java +++ b/libjava/javax/swing/DefaultComboBoxModel.java @@ -38,146 +38,191 @@ exception statement from your version. */ package javax.swing; import java.io.Serializable; +import java.util.Arrays; import java.util.Vector; + /** - * DefaultComboBoxModel - * @author Andrew Selkirk - * @version 1.0 + * DefaultComboBoxModel is a data model for JComboBox. This model keeps track + * of elements contained in the JComboBox as well as the current combo box + * selection. Whenever selection in the JComboBox changes, the ComboBoxModel + * will fire ListDataEvents to ComboBox's ListDataListeners. + * + * @author Andrew Selkirk + * @author Olga Rodimina + * @version 1.0 */ -public class DefaultComboBoxModel extends AbstractListModel - implements MutableComboBoxModel, Serializable +public class DefaultComboBoxModel extends AbstractListModel + implements MutableComboBoxModel, Serializable { static final long serialVersionUID = 6698657703676921904L; - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * list - */ - private Vector list; - - /** - * selectedItem - */ - private Object selectedItem; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultComboBoxModel - */ - public DefaultComboBoxModel() { - // TODO - } // DefaultComboBoxModel() - - /** - * Constructor DefaultComboBoxModel - * @param items TODO - */ - public DefaultComboBoxModel(Object[] items) { - // TODO - } // DefaultComboBoxModel() - - /** - * Constructor DefaultComboBoxModel - * @param vector TODO - */ - public DefaultComboBoxModel(Vector vector) { - // TODO - } // DefaultComboBoxModel() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * addElement - * @param object TODO - */ - public void addElement(Object object) { - // TODO - } // addElement() - - /** - * removeElementAt - * @param index TODO - */ - public void removeElementAt(int index) { - // TODO - } // removeElementAt() - - /** - * insertElementAt - * @param object TODO - * @param index TODO - */ - public void insertElementAt(Object object, int index) { - // TODO - } // insertElementAt() - - /** - * removeElement - * @param object TODO - */ - public void removeElement(Object object) { - // TODO - } // removeElement() - - /** - * removeAllElements - */ - public void removeAllElements() { - // TODO - } // removeAllElements() - - /** - * getSize - * @returns int - */ - public int getSize() { - return 0; // TODO - } // getSize() - - /** - * setSelectedItem - * @param object TODO - */ - public void setSelectedItem(Object object) { - // TODO - } // setSelectedItem() - - /** - * getSelectedItem - * @returns Object - */ - public Object getSelectedItem() { - return null; // TODO - } // getSelectedItem() - - /** - * getElementAt - * @param index TODO - * @returns Object - */ - public Object getElementAt(int index) { - return null; // TODO - } // getElementAt() - - /** - * getIndexOf - * @param object TODO - * @returns int - */ - public int getIndexOf(Object object) { - return 0; // TODO - } // getIndexOf() - - -} // DefaultComboBoxModel + /** + * List containing items in the combo box + */ + private Vector list; + + /** + * Currently selected item in the combo box list + */ + private Object selectedItem = null; + + /** + * Constructor DefaultComboBoxModel. Create empty JComboBox. + */ + public DefaultComboBoxModel() + { + list = new Vector(); + } + + /** + * Constructs new DefaultComboBoxModel object and initializes its item list + * to values in the given array. + * + * @param items array containing items of the combo box. + */ + public DefaultComboBoxModel(Object[] items) + { + list = new Vector(Arrays.asList(items)); + } + + /** + * Consturcts new DefaultComboBoxModel object and initializes its item list + * to values in the given vector. + * + * @param vector Vector containing items for this combo box. + */ + public DefaultComboBoxModel(Vector vector) + { + this.list = vector; + } + + /** + * This method adds element to the combo box list. It fires ListDataEvent + * indicating that component was added to the combo box to all of the + * JComboBox's registered ListDataListeners. + * + * @param object item to add to the combo box list + */ + public void addElement(Object object) + { + list.add(object); + fireIntervalAdded(this, list.size(), list.size()); + } + + /** + * This method removes element at the specified index from the combo box + * list. It fires ListDataEvent indicating that component was removed from + * the combo box list to all of the JComboBox's registered + * ListDataListeners. + * + * @param index index specifying location of the element to remove in the + * combo box list. + */ + public void removeElementAt(int index) + { + list.remove(index); + fireIntervalRemoved(this, index, index); + } + + /** + * This method inserts given object to the combo box list at the specified + * index. It fires ListDataEvent indicating that component was inserted to + * the combo box list to all of the JComboBox's registered + * ListDataListeners. + * + * @param object element to insert + * @param index index specifing position in the list where given element + * should be inserted. + */ + public void insertElementAt(Object object, int index) + { + list.insertElementAt(object, index); + fireIntervalAdded(this, index, index); + } + + /** + * Removes given object from the combo box list. It fires ListDataEvent + * indicating that component was removed from the combo box list to all of + * the JComboBox's registered ListDataListeners. + * + * @param object Element that will be removed from the combo box list + */ + public void removeElement(Object object) + { + int index = getIndexOf(object); + if (index != -1) + removeElementAt(index); + } + + /** + * Removes all the items from the JComboBox's item list. It fires + * ListDataEvent indicating that all the elements were removed from the + * combo box list to all of the JComboBox's registered ListDataListeners. + */ + public void removeAllElements() + { + int listSize = getSize(); + list.clear(); + fireIntervalAdded(this, 0, listSize - 1); + } + + /** + * Returns number of items in the combo box list + * + * @return number of items in the combo box list + */ + public int getSize() + { + return list.size(); + } + + /** + * Selects given object in the combo box list. This method fires + * ListDataEvent to all registered ListDataListeners of the JComboBox. The + * start and end index of the event is set to -1 to indicate combo box's + * selection has changed, and not its contents. + * + * @param object item to select in the JComboBox + */ + public void setSelectedItem(Object object) + { + selectedItem = object; + fireContentsChanged(this, -1, -1); + } + + /** + * Returns currently selected item in the combo box list + * + * @return currently selected item in the combo box list + */ + public Object getSelectedItem() + { + return selectedItem; + } + + /** + * Returns element in the combo box list located at the given index + * + * @param index specifying location of the element in the list + * + * @return return element in the combo box list located at the given index + */ + public Object getElementAt(int index) + { + return list.elementAt(index); + } + + /** + * Returns index of the specified object in the combo box list. + * + * @param object element to look for in the combo box list . + * + * @return Index specifying position of the specified element in combo box + * list. + */ + public int getIndexOf(Object object) + { + return list.indexOf(object); + } +} diff --git a/libjava/javax/swing/DefaultListCellRenderer.java b/libjava/javax/swing/DefaultListCellRenderer.java index cfb1f409dd7..fe4b3d07048 100644 --- a/libjava/javax/swing/DefaultListCellRenderer.java +++ b/libjava/javax/swing/DefaultListCellRenderer.java @@ -41,16 +41,18 @@ import java.awt.Component; import java.awt.Rectangle; import java.io.Serializable; import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; /** - * DefaultListCellRenderer + * DefaultListCellRenderer. This class is responsible for rendering list + * cells. * * @author Andrew Selkirk * @version 1.0 */ -public class DefaultListCellRenderer - extends JLabel implements ListCellRenderer, Serializable +public class DefaultListCellRenderer extends JLabel implements ListCellRenderer, + Serializable { static final long serialVersionUID = 7708947179685189462L; @@ -62,19 +64,22 @@ public class DefaultListCellRenderer } } - /** noFocusBorder */ - protected static Border noFocusBorder = null; // TODO + /** + * This border is used whenever renderer doesn't have a focus. + */ + protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); /** * getListCellRendererComponent * - * @param list TODO - * @param value TODO - * @param index TODO - * @param isSelected TODO - * @param cellHasFocus TODO + * @param list JList list for the 'value' + * @param value object that should be rendered in the cell + * @param index index of the cell + * @param isSelected draw cell highlighted if isSelected is true + * @param cellHasFocus draw focus rectangle around cell if the cell has + * focus * - * @return Component + * @return Component that will be painted to the desired cell. */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, @@ -86,31 +91,87 @@ public class DefaultListCellRenderer if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); + setBackground(list.getBackground()); + setForeground(list.getForeground()); } setEnabled(list.isEnabled()); setFont(list.getFont()); + + // Use focusCellHighlightBorder when renderer has focus and + // noFocusBorder otherwise + + if (cellHasFocus) + setBorder(UIManager.getBorder("List.focusCellHighlightBorder")); + else + setBorder(noFocusBorder); + return this; } - public void validate() {} - public void revalidate() {} - public void repaint(long tm, int x, int y, int w, int h) {} - public void repaint(Rectangle rect) {} - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue){} - public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {} - public void firePropertyChange(String propertyName, char oldValue, char newValue) {} - public void firePropertyChange(String propertyName, short oldValue, short newValue) {} - public void firePropertyChange(String propertyName, int oldValue, int newValue) {} - public void firePropertyChange(String propertyName, long oldValue, long newValue) {} - public void firePropertyChange(String propertyName, float oldValue, float newValue) {} - public void firePropertyChange(String propertyName, double oldValue, double newValue) {} - public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {} + public void validate() + { + } + + public void revalidate() + { + } + + public void repaint(long tm, int x, int y, int w, int h) + { + } + + public void repaint(Rectangle rect) + { + } + + protected void firePropertyChange(String propertyName, Object oldValue, + Object newValue) + { + } + + public void firePropertyChange(String propertyName, byte oldValue, + byte newValue) + { + } + + public void firePropertyChange(String propertyName, char oldValue, + char newValue) + { + } + + public void firePropertyChange(String propertyName, short oldValue, + short newValue) + { + } + + public void firePropertyChange(String propertyName, int oldValue, + int newValue) + { + } + + public void firePropertyChange(String propertyName, long oldValue, + long newValue) + { + } + + public void firePropertyChange(String propertyName, float oldValue, + float newValue) + { + } + + public void firePropertyChange(String propertyName, double oldValue, + double newValue) + { + } + + public void firePropertyChange(String propertyName, boolean oldValue, + boolean newValue) + { + } } diff --git a/libjava/javax/swing/DefaultListSelectionModel.java b/libjava/javax/swing/DefaultListSelectionModel.java index 67ad1df4173..4b8ddc355d3 100644 --- a/libjava/javax/swing/DefaultListSelectionModel.java +++ b/libjava/javax/swing/DefaultListSelectionModel.java @@ -264,7 +264,7 @@ public class DefaultListSelectionModel implements Cloneable, { end = i; } - fireSelectionValueChanged(beg, end, valueIsAdjusting); + fireValueChanged(beg, end, valueIsAdjusting); } /** @@ -409,7 +409,7 @@ public class DefaultListSelectionModel implements Cloneable, int hi = Math.max(index0, index1); sel.set(lo, hi+1); - fireSelectionValueChanged(lo, hi, valueIsAdjusting); + fireValueChanged(lo, hi, valueIsAdjusting); } @@ -429,7 +429,7 @@ public class DefaultListSelectionModel implements Cloneable, int lo = Math.min(index0, index1); int hi = Math.max(index0, index1); sel.clear(lo, hi+1); - fireSelectionValueChanged(lo, hi, valueIsAdjusting); + fireValueChanged(lo, hi, valueIsAdjusting); } /** @@ -439,7 +439,7 @@ public class DefaultListSelectionModel implements Cloneable, { int sz = sel.size(); sel.clear(); - fireSelectionValueChanged(0, sz, valueIsAdjusting); + fireValueChanged(0, sz, valueIsAdjusting); } /** @@ -460,7 +460,7 @@ public class DefaultListSelectionModel implements Cloneable, int lo = Math.min(index0, index1); int hi = Math.max(index0, index1); sel.set(lo, hi+1); - fireSelectionValueChanged(lo, hi, valueIsAdjusting); + fireValueChanged(lo, hi, valueIsAdjusting); } /** @@ -522,8 +522,8 @@ public class DefaultListSelectionModel implements Cloneable, * @param isAdjusting Whether this change is part of a seqence of adjustments * made to the selection, such as during interactive scrolling */ - public void fireSelectionValueChanged(int firstIndex, int lastIndex, - boolean isAdjusting) + protected void fireValueChanged(int firstIndex, int lastIndex, + boolean isAdjusting) { ListSelectionEvent evt = new ListSelectionEvent(this, firstIndex, lastIndex, isAdjusting); diff --git a/libjava/javax/swing/InputMap.java b/libjava/javax/swing/InputMap.java index fdcc8280fd3..c737ae4db95 100644 --- a/libjava/javax/swing/InputMap.java +++ b/libjava/javax/swing/InputMap.java @@ -89,9 +89,9 @@ public class InputMap { Object result = inputMap.get(keystroke); - if (result == null) - result = parent.get(keystroke); - return result; + if (result == null && parent != null) + result = parent.get(keystroke); + return result; } /** diff --git a/libjava/javax/swing/JCheckBox.java b/libjava/javax/swing/JCheckBox.java index f5cc78aceda..8490c0b91c0 100644 --- a/libjava/javax/swing/JCheckBox.java +++ b/libjava/javax/swing/JCheckBox.java @@ -114,7 +114,7 @@ public class JCheckBox extends JToggleButton } /** - * Returns a string that specifies the name of the L&F class + * Returns a string that specifies the name of the Look and Feel class * that renders this component. */ public String getUIClassID() diff --git a/libjava/javax/swing/JColorChooser.java b/libjava/javax/swing/JColorChooser.java index 70dde6a19b3..6ba70ce99ba 100644 --- a/libjava/javax/swing/JColorChooser.java +++ b/libjava/javax/swing/JColorChooser.java @@ -35,11 +35,16 @@ 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 javax.swing; +import java.awt.AWTError; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.Dialog; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.ObjectOutputStream; @@ -47,314 +52,521 @@ import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.swing.colorchooser.AbstractColorChooserPanel; +import javax.swing.colorchooser.ColorChooserComponentFactory; import javax.swing.colorchooser.ColorSelectionModel; +import javax.swing.colorchooser.DefaultColorSelectionModel; import javax.swing.plaf.ColorChooserUI; + /** - * JColorChooser - * @author Andrew Selkirk - * @version 1.0 + * The JColorChooser is a Swing widget that offers users different ways to + * select a color. By default, three different panels are presented to the + * user that are capable of changing the selected color. There are three ways + * to utilize JColorChooser. The first is to build a JColorChooser and add it + * to the content pane. The second is to use the createDialog method to + * create a JDialog that holds a JColorChooser. The third is to show a + * JColorChooser in a JDialog directly using the showDialog method. */ -public class JColorChooser extends JComponent implements Accessible { - +public class JColorChooser extends JComponent implements Accessible +{ + /** DOCUMENT ME! */ private static final long serialVersionUID = 9168066781620640889L; - - //------------------------------------------------------------- - // Classes ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * AccessibleJColorChooser - */ - protected class AccessibleJColorChooser extends JComponent.AccessibleJComponent { - - private static final long serialVersionUID = -2038297864782299082L; - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor AccessibleJColorChooser - * @param component TODO - */ - protected AccessibleJColorChooser() + + /** + * AccessibleJColorChooser + */ + protected class AccessibleJColorChooser + extends JComponent.AccessibleJComponent + { + /** DOCUMENT ME! */ + private static final long serialVersionUID = -2038297864782299082L; + + /** + * Constructor AccessibleJColorChooser + */ + protected AccessibleJColorChooser() + { + } + + /** + * getAccessibleRole + * + * @return AccessibleRole + */ + public AccessibleRole getAccessibleRole() + { + return AccessibleRole.COLOR_CHOOSER; + } // getAccessibleRole() + } // AccessibleJColorChooser + + /** The model used with the JColorChooser. */ + private ColorSelectionModel selectionModel; + + /** The preview panel associated with the JColorChooser. */ + private JComponent previewPanel; + + /** + * The set of AbstractColorChooserPanels associated with the JColorChooser. + */ + private AbstractColorChooserPanel[] chooserPanels; + + /** A Drag and Drop property. */ + private boolean dragEnabled; + + /** + * The property fired by the JColorChooser when the selectionModel property + * changes. + */ + public static final String SELECTION_MODEL_PROPERTY = "selectionModel"; + + /** + * The property fired by the JColorChooser when the previewPanel property + * changes. + */ + public static final String PREVIEW_PANEL_PROPERTY = "previewPanel"; + + /** + * The property fired by the JColorChooser when the chooserPanels property + * changes. + */ + public static final String CHOOSER_PANELS_PROPERTY = "chooserPanels"; + + /** accessibleContext */ + protected AccessibleContext accessibleContext; + + /** + * This method creates a new JColorChooser with the default initial color. + */ + public JColorChooser() + { + this(new DefaultColorSelectionModel()); + } // JColorChooser() + + /** + * This method creates a new JColorChooser with the given initial color. + * + * @param initial The initial color. + */ + public JColorChooser(Color initial) + { + this(new DefaultColorSelectionModel(initial)); + } // JColorChooser() + + /** + * This method creates a new JColorChooser with the given model. The model + * will dictate what the initial color for the JColorChooser is. + * + * @param model The Model to use with the JColorChooser. + */ + public JColorChooser(ColorSelectionModel model) + { + if (model == null) + model = new DefaultColorSelectionModel(); + selectionModel = model; + updateUI(); + } // JColorChooser() + + /** + * This method sets the current color for the JColorChooser. + * + * @param color The new color for the JColorChooser. + */ + public void setColor(Color color) + { + if (color != null) + selectionModel.setSelectedColor(color); + } // setColor() + + /** + * This method sets the current color for the JColorChooser using RGB + * values. + * + * @param r The red value. + * @param g The green value. + * @param b The blue value. + */ + public void setColor(int r, int g, int b) + { + selectionModel.setSelectedColor(new Color(r, g, b)); + } // setColor() + + /** + * This method sets the current color for the JColorChooser using the + * integer value. Bits 0-7 represent the blue value. Bits 8-15 represent + * the green value. Bits 16-23 represent the red value. + * + * @param color The new current color of the JColorChooser. + */ + public void setColor(int color) + { + setColor(new Color(color, false)); + } // setColor() + + /** + * This method shows a JColorChooser inside a JDialog. The JDialog will + * block until it is hidden. The JDialog comes with three buttons: OK, + * Cancel, and Reset. Pressing OK or Cancel hide the JDialog. Pressing + * Reset will reset the JColorChooser to its initial value. + * + * @param component The Component that parents the JDialog. + * @param title The title displayed in the JDialog. + * @param initial The initial color. + * + * @return The selected color. + */ + public static Color showDialog(Component component, String title, + Color initial) + { + JColorChooser choose = new JColorChooser(initial); + + JDialog dialog = createDialog(component, title, true, choose, null, null); + + dialog.getContentPane().add(choose); + dialog.pack(); + dialog.show(); + + return choose.getColor(); + } // showDialog() + + /** + * This is a helper method to make the given JDialog block until it is + * hidden. + * + * @param dialog The JDialog to block. + */ + private static void makeModal(JDialog dialog) + { + try + { + synchronized (dialog) { + while (dialog.isVisible()) + dialog.wait(); } + } + catch (InterruptedException e) + { + } + } + + /** + * This is a helper method to find the first Frame or Dialog ancestor of the + * given Component. + * + * @param c The Component to find ancestors for. + * + * @return A Frame or Dialog ancestor. Null if none are found. + */ + private static Component findParent(Component c) + { + Component parent = SwingUtilities.getAncestorOfClass(Frame.class, c); + if (parent != null) + return parent; + parent = SwingUtilities.getAncestorOfClass(Dialog.class, c); + return parent; + } + + /** + * This method will take the given JColorChooser and place it in a JDialog + * with the given modal property. Three buttons are displayed in the + * JDialog: OK, Cancel and Reset. If OK or Cancel are pressed, the JDialog + * is hidden. If Reset is pressed, then the JColorChooser will take on its + * default color value. The given okListener will be registered to the OK + * button and the cancelListener will be registered to the Cancel button. + * If the modal property is set, then the JDialog will block until it is + * hidden. + * + * @param component The Component that will parent the JDialog. + * @param title The title displayed in the JDialog. + * @param modal The modal property. + * @param chooserPane The JColorChooser to place in the JDialog. + * @param okListener The ActionListener to register to the OK button. + * @param cancelListener The ActionListener to register to the Cancel + * button. + * + * @return A JDialog with the JColorChooser inside of it. + * + * @throws AWTError If the component is not a suitable parent. + */ + public static JDialog createDialog(Component component, String title, + boolean modal, JColorChooser chooserPane, + ActionListener okListener, + ActionListener cancelListener) + { + Component parent = findParent(component); + if (parent == null) + throw new AWTError("No suitable parent found for Component."); + JDialog dialog; + if (parent instanceof Frame) + dialog = new ModalDialog((Frame) parent, title); + else + dialog = new ModalDialog((Dialog) parent, title); + dialog.setModal(modal); + + dialog.getContentPane().setLayout(new BorderLayout()); + + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout()); + + ActionListener al = new DefaultOKCancelListener(dialog); + + JButton ok = new JButton("OK"); + ok.addActionListener(okListener); + ok.addActionListener(al); + + JButton cancel = new JButton("Cancel"); + cancel.addActionListener(cancelListener); + cancel.addActionListener(al); + + JButton reset = new JButton("Reset"); + reset.addActionListener(new DefaultResetListener(chooserPane)); + + dialog.getContentPane().add(chooserPane, BorderLayout.NORTH); + + panel.add(ok); + panel.add(cancel); + panel.add(reset); + + dialog.getContentPane().add(panel, BorderLayout.SOUTH); + + return dialog; + } // createDialog() + + /** + * This method returns the UI Component used for this JColorChooser. + * + * @return The UI Component for this JColorChooser. + */ + public ColorChooserUI getUI() + { + return (ColorChooserUI) ui; + } // getUI() - /** - * getAccessibleRole - * @returns AccessibleRole - */ - public AccessibleRole getAccessibleRole() { - return AccessibleRole.COLOR_CHOOSER; - } // getAccessibleRole() - - - } // AccessibleJColorChooser - - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * uiClassID - */ - private static final String uiClassID = "ColorChooserUI"; - - /** - * selectionModel - */ - private ColorSelectionModel selectionModel; - - /** - * previewPanel - */ - private JComponent previewPanel; - - /** - * chooserPanels - */ - private AbstractColorChooserPanel[] chooserPanels; - - /** - * SELECTION_MODEL_PROPERTY - */ - public static final String SELECTION_MODEL_PROPERTY = "selectionModel"; - - /** - * PREVIEW_PANEL_PROPERTY - */ - public static final String PREVIEW_PANEL_PROPERTY = "previewPanel"; - - /** - * CHOOSER_PANELS_PROPERTY - */ - public static final String CHOOSER_PANELS_PROPERTY = "chooserPanels"; - - /** - * accessibleContext - */ - protected AccessibleContext accessibleContext; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor JColorChooser - */ - public JColorChooser() { - // TODO - } // JColorChooser() - - /** - * Constructor JColorChooser - * @param initial TODO - */ - public JColorChooser(Color initial) { - // TODO - } // JColorChooser() - - /** - * Constructor JColorChooser - * @param model TODO - */ - public JColorChooser(ColorSelectionModel model) { - // TODO - } // JColorChooser() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param stream TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream stream) throws IOException { - // TODO - } // writeObject() - - /** - * setColor - * @param color TODO - */ - public void setColor(Color color) { - // TODO - } // setColor() - - /** - * setColor - * @param r TODO - * @param g TODO - * @param b TODO - */ - public void setColor(int r, int g, int b) { - // TODO - } // setColor() - - /** - * setColor - * @param color TODO - */ - public void setColor(int color) { - // TODO - } // setColor() - - /** - * showDialog - * @param component TODO - * @param title TODO - * @param initial TODO - * @returns Color - */ - public static Color showDialog(Component component, String title, - Color initial) { - return null; // TODO - } // showDialog() - - /** - * createDialog - * @param component TODO - * @param title TODO - * @param modal TODO - * @param chooserPane TODO - * @param okListener TODO - * @param cancelListener TODO - * @returns JDialog - */ - public static JDialog createDialog(Component component, String title, - boolean modal, JColorChooser chooserPane, - ActionListener okListener, ActionListener cancelListener) { - return null; // TODO - } // createDialog() - - /** - * getUI - * @returns ColorChooserUI - */ - public ColorChooserUI getUI() { - return (ColorChooserUI) ui; - } // getUI() - - /** - * setUI - * @param ui TODO - */ - public void setUI(ColorChooserUI ui) { - super.setUI(ui); - } // setUI() - - /** - * updateUI - */ - public void updateUI() { - setUI((ColorChooserUI) UIManager.get(this)); - invalidate(); - } // updateUI() - - /** - * getUIClassID - * @returns String - */ - public String getUIClassID() { - return uiClassID; - } // getUIClassID() - - /** - * getColor - * @returns Color - */ - public Color getColor() { - return null; // TODO - } // getColor() - - /** - * setPreviewPanel - * @param component TODO - */ - public void setPreviewPanel(JComponent component) { - // TODO - } // setPreviewPanel() - - /** - * getPreviewPanel - * @returns JComponent - */ - public JComponent getPreviewPanel() { - return null; // TODO - } // getPreviewPanel() - - /** - * addChooserPanel - * @param panel TODO - */ - public void addChooserPanel(AbstractColorChooserPanel panel) { - // TODO - } // addChooserPanel() - - /** - * removeChooserPanel - * @param panel TODO - * @returns AbstractColorChooserPanel - */ - public AbstractColorChooserPanel removeChooserPanel( - AbstractColorChooserPanel panel) { - return null; // TODO - } // removeChooserPanel() - - /** - * setChooserPanels - * @param panels TODO - */ - public void setChooserPanels(AbstractColorChooserPanel[] panels) { - // TODO - } // setChooserPanels() - - /** - * getChooserPanels - * @returns AbstractColorChooserPanel[] - */ - public AbstractColorChooserPanel[] getChooserPanels() { - return null; // TODO - } // getChooserPanels() - - /** - * getSelectionModel - * @returns ColorSelectionModel - */ - public ColorSelectionModel getSelectionModel() { - return null; // TODO - } // getSelectionModel() - - /** - * setSelectionModel - * @param model TODO - */ - public void setSelectionModel(ColorSelectionModel model) { - // TODO - } // setSelectionModel() - - /** - * paramString - * @returns String - */ - protected String paramString() { - return null; // TODO - } // paramString() + /** + * This method sets the UI Component used for this JColorChooser. + * + * @param ui The UI Component to use with this JColorChooser. + */ + public void setUI(ColorChooserUI ui) + { + super.setUI(ui); + } // setUI() + + /** + * This method resets the UI Component property to the Look and Feel + * default. + */ + public void updateUI() + { + setUI((ColorChooserUI) UIManager.getUI(this)); + revalidate(); + } // updateUI() + + /** + * This method returns a String identifier for the UI Class to be used with + * the JColorChooser. + * + * @return The String identifier for the UI Class. + */ + public String getUIClassID() + { + return "ColorChooserUI"; + } // getUIClassID() + + /** + * This method returns the current color for the JColorChooser. + * + * @return The current color for the JColorChooser. + */ + public Color getColor() + { + return selectionModel.getSelectedColor(); // TODO + } // getColor() + + /** + * This method changes the previewPanel property for the JTabbedPane. The + * previewPanel is responsible for indicating the current color of the + * JColorChooser. + * + * @param component The Component that will act as the previewPanel. + */ + public void setPreviewPanel(JComponent component) + { + if (component != previewPanel) + { + JComponent old = previewPanel; + previewPanel = component; + firePropertyChange(PREVIEW_PANEL_PROPERTY, old, previewPanel); + } + } // setPreviewPanel() + + /** + * This method returns the current previewPanel used with this + * JColorChooser. + * + * @return The current previewPanel. + */ + public JComponent getPreviewPanel() + { + return previewPanel; // TODO + } // getPreviewPanel() + + /** + * This method adds the given AbstractColorChooserPanel to the list of the + * JColorChooser's chooserPanels. + * + * @param panel The AbstractColorChooserPanel to add. + */ + public void addChooserPanel(AbstractColorChooserPanel panel) + { + if (panel == null) + return; + AbstractColorChooserPanel[] old = chooserPanels; + AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[(old == null) + ? 1 + : old.length + + 1]; + if (old != null) + System.arraycopy(old, 0, newPanels, 0, old.length); + newPanels[newPanels.length - 1] = panel; + chooserPanels = newPanels; + panel.installChooserPanel(this); + firePropertyChange(CHOOSER_PANELS_PROPERTY, old, newPanels); + } // addChooserPanel() + + /** + * This method removes the given AbstractColorChooserPanel from the + * JColorChooser's list of chooserPanels. + * + * @param panel The AbstractColorChooserPanel to remove. + * + * @return The AbstractColorChooserPanel that was removed. + */ + public AbstractColorChooserPanel removeChooserPanel(AbstractColorChooserPanel panel) + { + int index = -1; + for (int i = 0; i < chooserPanels.length; i++) + if (panel == chooserPanels[i]) + { + index = i; + break; + } + + if (index == -1) + return null; + + AbstractColorChooserPanel[] old = chooserPanels; + if (chooserPanels.length == 1) + chooserPanels = null; + else + { + AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[chooserPanels.length + - 1]; + System.arraycopy(chooserPanels, 0, newPanels, 0, index); + System.arraycopy(chooserPanels, index, newPanels, index - 1, + chooserPanels.length - index); + chooserPanels = newPanels; + } + panel.uninstallChooserPanel(this); + firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels); + return panel; + } + + /** + * This method sets the chooserPanels property for this JColorChooser. + * + * @param panels The new set of AbstractColorChooserPanels to use. + */ + public void setChooserPanels(AbstractColorChooserPanel[] panels) + { + if (panels != chooserPanels) + { + if (chooserPanels != null) + for (int i = 0; i < chooserPanels.length; i++) + if (chooserPanels[i] != null) + chooserPanels[i].uninstallChooserPanel(this); + + AbstractColorChooserPanel[] old = chooserPanels; + chooserPanels = panels; + + if (panels != null) + for (int i = 0; i < panels.length; i++) + if (panels[i] != null) + panels[i].installChooserPanel(this); + + firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels); + } + } // setChooserPanels() + + /** + * This method returns the AbstractColorChooserPanels used with this + * JColorChooser. + * + * @return The AbstractColorChooserPanels used with this JColorChooser. + */ + public AbstractColorChooserPanel[] getChooserPanels() + { + return chooserPanels; + } // getChooserPanels() + + /** + * This method returns the ColorSelectionModel used with this JColorChooser. + * + * @return The ColorSelectionModel. + */ + public ColorSelectionModel getSelectionModel() + { + return selectionModel; + } // getSelectionModel() + + /** + * This method sets the ColorSelectionModel to be used with this + * JColorChooser. + * + * @param model The ColorSelectionModel to be used with this JColorChooser. + * + * @throws AWTError If the given model is null. + */ + public void setSelectionModel(ColorSelectionModel model) + { + if (model == null) + throw new AWTError("ColorSelectionModel is not allowed to be null."); + selectionModel = model; + } // setSelectionModel() + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getDragEnabled() + { + return dragEnabled; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setDragEnabled(boolean b) + { + dragEnabled = b; + } + + /** + * This method returns a String describing the JColorChooser. + * + * @return A String describing the JColorChooser. + */ + protected String paramString() + { + return "JColorChooser"; + } // paramString() /** * getAccessibleContext + * * @return AccessibleContext */ public AccessibleContext getAccessibleContext() @@ -364,4 +576,130 @@ public class JColorChooser extends JComponent implements Accessible { return accessibleContext; } + + /** + * A helper class that hides a JDialog when the action is performed. + */ + static class DefaultOKCancelListener implements ActionListener + { + /** The JDialog to hide. */ + private JDialog dialog; + + /** + * Creates a new DefaultOKCancelListener with the given JDialog to hide. + * + * @param dialog The JDialog to hide. + */ + public DefaultOKCancelListener(JDialog dialog) + { + super(); + this.dialog = dialog; + } + + /** + * This method hides the JDialog when called. + * + * @param e The ActionEvent. + */ + public void actionPerformed(ActionEvent e) + { + dialog.hide(); + } + } + + /** + * This method resets the JColorChooser color to the initial color when the + * action is performed. + */ + static class DefaultResetListener implements ActionListener + { + /** The JColorChooser to reset. */ + private JColorChooser chooser; + + /** The initial color. */ + private Color init; + + /** + * Creates a new DefaultResetListener with the given JColorChooser. + * + * @param chooser The JColorChooser to reset. + */ + public DefaultResetListener(JColorChooser chooser) + { + super(); + this.chooser = chooser; + init = chooser.getColor(); + } + + /** + * This method resets the JColorChooser to its initial color. + * + * @param e The ActionEvent. + */ + public void actionPerformed(ActionEvent e) + { + chooser.setColor(init); + } + } + + /** + * This is a custom JDialog that will notify when it is hidden and the modal + * property is set. + */ + static class ModalDialog extends JDialog + { + /** The modal property. */ + private boolean modal; + + /** + * Creates a new ModalDialog object with the given parent and title. + * + * @param parent The parent of the JDialog. + * @param title The title of the JDialog. + */ + public ModalDialog(Frame parent, String title) + { + super(parent, title); + } + + /** + * Creates a new ModalDialog object with the given parent and title. + * + * @param parent The parent of the JDialog. + * @param title The title of the JDialog. + */ + public ModalDialog(Dialog parent, String title) + { + super(parent, title); + } + + /** + * This method sets the modal property. + * + * @param modal The modal property. + */ + public void setModal(boolean modal) + { + this.modal = modal; + } + + /** + * This method shows the ModalDialog. + */ + public void show() + { + super.show(); + if (modal) + makeModal(this); + } + + /** + * This method hides the ModalDialog. + */ + public synchronized void hide() + { + super.hide(); + notifyAll(); + } + } } diff --git a/libjava/javax/swing/JComboBox.java b/libjava/javax/swing/JComboBox.java index b66dcb3a9a8..9d480dc7c27 100644 --- a/libjava/javax/swing/JComboBox.java +++ b/libjava/javax/swing/JComboBox.java @@ -35,761 +35,958 @@ 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 javax.swing; +import java.awt.Component; +import java.awt.Dimension; import java.awt.ItemSelectable; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Vector; - import javax.accessibility.Accessible; import javax.accessibility.AccessibleAction; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleSelection; +import javax.swing.JComponent; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.PopupMenuListener; import javax.swing.plaf.ComboBoxUI; + /** - * JComboBox - * @author Andrew Selkirk - * @version 1.0 + * JComboBox. JComboBox is a container, that keeps track of elements added to + * it by the user. JComboBox allows user to select any item in its list and + * displays the selected item to the user. JComboBox also can show/hide popup + * menu containing its list of item whenever the mouse is pressed over it. + * + * @author Andrew Selkirk + * @author Olga Rodimina */ -public class JComboBox extends JComponent - implements ItemSelectable, ListDataListener, ActionListener, Accessible +public class JComboBox extends JComponent implements ItemSelectable, + ListDataListener, + ActionListener, + Accessible { private static final long serialVersionUID = 5654585963292734470L; /** - * AccessibleJComboBox + * KeySelectionManager interface. Class implementing this interface are + * responsible for matching key characters typed by the user with combo + * box's items. */ - protected class AccessibleJComboBox extends AccessibleJComponent - implements AccessibleAction, AccessibleSelection + public static interface KeySelectionManager { - private static final long serialVersionUID = 8217828307256675666L; + int selectionForKey(char aKey, ComboBoxModel aModel); + } + + /** + * Maximum number of rows that should be visible by default in the + * JComboBox's popup + */ + public static final int DEFAULT_MAXIMUM_ROW_COUNT = 8; + + /** + * Fired in a PropertyChangeEvent when the 'editable' property changes. + */ + public static final String EDITABLE_CHANGED_PROPERTY = "editable"; + + /** + * Fired in a PropertyChangeEvent when the 'maximumRowCount' property + * changes. + */ + public static final String MAXIMUM_ROW_COUNT_CHANGED_PROPERTY = "maximumRowCount"; + + /** + * Fired in a PropertyChangeEvent when the 'enabled' property changes. + */ + public static final String ENABLED_CHANGED_PROPERTY = "enabled"; + + /** + * Fired in a PropertyChangeEvent when the 'renderer' property changes. + */ + public static final String RENDERER_CHANGED_PROPERTY = "renderer"; + + /** + * Fired in a PropertyChangeEvent when the 'editor' property changes. + */ + public static final String EDITOR_CHANGED_PROPERTY = "editor"; + + /** + * Fired in a PropertyChangeEvent when the 'dataModel' property changes. + */ + public static final String MODEL_CHANGED_PROPERTY = "dataModel"; + + /** + * name for the UI delegate for this combo box. + */ + private static final String uiClassID = "ComboBoxUI"; + + /** + * dataModel used by JComboBox to keep track of its list data and currently + * selected element in the list. + */ + protected ComboBoxModel dataModel; + + /** + * Renderer renders(paints) every object in the combo box list in its + * associated list cell. This ListCellRenderer is used only when this + * JComboBox is uneditable. + */ + protected ListCellRenderer renderer; + + /** + * editor that is responsible for editting an object in a combo box list + */ + protected ComboBoxEditor editor; + + /** + * Number of rows that will be visible in the JComboBox's popup. + */ + protected int maximumRowCount; + + /** + * This field indicates if textfield of this JComboBox is editable or not. + */ + protected boolean isEditable; + + /** + * This field is reference to the current selection of the combo box. + */ + protected Object selectedItemReminder; + + /** + * keySelectionManager + */ + protected KeySelectionManager keySelectionManager; + + /** + * This actionCommand is used in ActionEvent that is fired to JComboBox's + * ActionListeneres. + */ + protected String actionCommand; + + /** + * This property indicates if heavyweight popup or lightweight popup will be + * used to diplay JComboBox's elements. + */ + protected boolean lightWeightPopupEnabled; + + /** + * The action taken when new item is selected in the JComboBox + */ + private Action action; + + /** + * since 1.4 If this field is set then comboBox's display area for the + * selected item will be set by default to this value. + */ + private Object prototypeDisplayValue; + + /** + * Constructs JComboBox object with specified data model for it. The first + * item in the specified data model is selected by default. + * + * @param model Data model that will be used by this JComboBox to keep track + * of its list of items. + */ + public JComboBox(ComboBoxModel model) + { + setEditable(false); + setEnabled(true); + setMaximumRowCount(DEFAULT_MAXIMUM_ROW_COUNT); + setModel(model); + setActionCommand("comboBoxChanged"); + + // by default set selected item to the first element in the combo box + if (getItemCount() != 0) + setSelectedItem(getItemAt(0)); + + lightWeightPopupEnabled = true; + isEditable = false; + + updateUI(); + } + + /** + * Constructs JComboBox with specified list of items. + * + * @param itemArray array containing list of items for this JComboBox + */ + public JComboBox(Object[] itemArray) + { + this(new DefaultComboBoxModel(itemArray)); + } + + /** + * Constructs JComboBox object with specified list of items. + * + * @param itemVector vector containing list of items for this JComboBox. + */ + public JComboBox(Vector itemVector) + { + this(new DefaultComboBoxModel(itemVector)); + } + + /** + * Constructor. Creates new empty JComboBox. ComboBox's data model is set to + * DefaultComboBoxModel. + */ + public JComboBox() + { + this(new DefaultComboBoxModel()); + } + + private void writeObject(ObjectOutputStream stream) throws IOException + { + } + + /** + * This method returns true JComboBox is editable and false otherwise + * + * @return boolean true if JComboBox is editable and false otherwise + */ + public boolean isEditable() + { + return isEditable; + } - /** - * Constructor AccessibleJComboBox - * @param component TODO + /* + * This method adds ancestor listener to this JComboBox. + */ + protected void installAncestorListener() + { + /* FIXME: Need to implement. + * + * Need to add ancestor listener to this JComboBox. This listener + * should close combo box's popup list of items whenever it + * receives an AncestorEvent. */ - protected AccessibleJComboBox() - { - } + } + + /** + * Set the "UI" property of the combo box, which is a look and feel class + * responsible for handling comboBox's input events and painting it. + * + * @param ui The new "UI" property + */ + public void setUI(ComboBoxUI ui) + { + super.setUI(ui); + } + + /** + * This method sets this comboBox's UI to the UIManager's default for the + * current look and feel. + */ + public void updateUI() + { + setUI((ComboBoxUI) UIManager.getUI(this)); + invalidate(); + } + + /** + * This method returns the String identifier for the UI class to the used + * with the JComboBox. + * + * @return The String identifier for the UI class. + */ + public String getUIClassID() + { + return uiClassID; + } + + /** + * This method returns the UI used to display the JComboBox. + * + * @return The UI used to display the JComboBox. + */ + public ComboBoxUI getUI() + { + return (ComboBoxUI) ui; + } + + /** + * Set the data model for this JComboBox. This un-registers all listeners + * associated with the current model, and re-registers them with the new + * model. + * + * @param newDataModel The new data model for this JComboBox + */ + public void setModel(ComboBoxModel newDataModel) + { + if (this.dataModel == newDataModel) + return; + + if (this.dataModel != null) + // remove all listeners currently registered with the model. + dataModel.removeListDataListener(this); + + ComboBoxModel oldDataModel = this.dataModel; + this.dataModel = newDataModel; + + if (this.dataModel != null) + // register all listeners with the new data model + dataModel.addListDataListener(this); + + firePropertyChange(MODEL_CHANGED_PROPERTY, oldDataModel, this.dataModel); + } + + /** + * This method returns data model for this comboBox. + * + * @return ComboBoxModel containing items for this combo box. + */ + public ComboBoxModel getModel() + { + return dataModel; + } + + /** + * This method sets JComboBox's popup to be either lightweight or + * heavyweight. If 'enabled' is true then lightweight popup is used and + * heavyweight otherwise. By default lightweight popup is used to display + * this JComboBox's elements. + * + * @param enabled indicates if lightweight popup or heavyweight popup should + * be used to display JComboBox's elements. + */ + public void setLightWeightPopupEnabled(boolean enabled) + { + this.lightWeightPopupEnabled = enabled; + } + + /** + * This method returns whether popup menu that is used to display list of + * combo box's item is lightWeight or not. + * + * @return boolean true if popup menu is lightweight and false otherwise. + */ + public boolean isLightWeightPopupEnabled() + { + return lightWeightPopupEnabled; + } + + /** + * This method sets editability of the combo box. If combo box is editable + * the user can choose component from the combo box list by typing + * component's name in the editor(JTextfield by default). Otherwise if not + * editable, the user should use the list to choose the component. This + * method fires PropertyChangeEvents to JComboBox's registered + * PropertyChangeListeners to indicate that 'editable' property of the + * JComboBox has changed. + * + * @param editable indicates if the JComboBox's textfield should be editable + * or not. + */ + public void setEditable(boolean editable) + { + if (this.isEditable != editable) + { + this.isEditable = editable; + firePropertyChange(EDITABLE_CHANGED_PROPERTY, ! isEditable, isEditable); + } + } + + /** + * Sets number of rows that should be visible in this JComboBox's popup. If + * this JComboBox's popup has more elements that maximum number or rows + * then popup will have a scroll pane to allow users to view other + * elements. + * + * @param rowCount number of rows that will be visible in JComboBox's popup. + */ + public void setMaximumRowCount(int rowCount) + { + if (maximumRowCount != rowCount) + { + int oldMaximumRowCount = this.maximumRowCount; + this.maximumRowCount = rowCount; + firePropertyChange(MAXIMUM_ROW_COUNT_CHANGED_PROPERTY, + oldMaximumRowCount, this.maximumRowCount); + } + } + + /** + * This method returns number of rows visible in the JComboBox's list of + * items. + * + * @return int maximun number of visible rows in the JComboBox's list. + */ + public int getMaximumRowCount() + { + return maximumRowCount; + } + + /** + * This method sets cell renderer for this JComboBox that will be used to + * paint combo box's items. The Renderer should only be used only when + * JComboBox is not editable. In the case when JComboBox is editable the + * editor must be used. This method also fires PropertyChangeEvent when + * cellRendered for this JComboBox has changed. + * + * @param aRenderer cell renderer that will be used by this JComboBox to + * paint its elements. + */ + public void setRenderer(ListCellRenderer aRenderer) + { + if (this.renderer != aRenderer) + { + ListCellRenderer oldRenderer = this.renderer; + this.renderer = aRenderer; + firePropertyChange(RENDERER_CHANGED_PROPERTY, oldRenderer, + this.renderer); + } + } + + /** + * This method returns renderer responsible for rendering selected item in + * the combo box + * + * @return ListCellRenderer + */ + public ListCellRenderer getRenderer() + { + return renderer; + } + + /** + * Sets editor for this JComboBox + * + * @param newEditor ComboBoxEditor for this JComboBox. This method fires + * PropertyChangeEvent when 'editor' property is changed. + */ + public void setEditor(ComboBoxEditor newEditor) + { + if (editor == newEditor) + return; + + if (editor != null) + editor.removeActionListener(this); + + ComboBoxEditor oldEditor = editor; + editor = newEditor; + + if (editor != null) + editor.addActionListener(this); + + firePropertyChange(EDITOR_CHANGED_PROPERTY, oldEditor, editor); + } + + /** + * Returns editor component that is responsible for displaying/editting + * selected item in the combo box. + * + * @return ComboBoxEditor + */ + public ComboBoxEditor getEditor() + { + return editor; + } + + /** + * Forces combo box to select given item + * + * @param item element in the combo box to select. + */ + public void setSelectedItem(Object item) + { + dataModel.setSelectedItem(item); + } + + /** + * Returns currently selected item in the combo box. + * + * @return element that is currently selected in this combo box. + */ + public Object getSelectedItem() + { + Object item = dataModel.getSelectedItem(); + + if (item == null && getItemCount() != 0) + item = getItemAt(0); + + return item; + } - /** - * getAccessibleChildrenCount - * @returns int - */ - public int getAccessibleChildrenCount() { - return 0; // TODO - } // getAccessibleChildrenCount() - - /** - * getAccessibleChild - * @param value0 TODO - * @returns Accessible - */ - public Accessible getAccessibleChild(int value0) { - return null; // TODO - } // getAccessibleChild() - - /** - * getAccessibleSelection - * @returns AccessibleSelection - */ - public AccessibleSelection getAccessibleSelection() { - return null; // TODO - } // getAccessibleSelection() - - /** - * getAccessibleSelection - * @param value0 TODO - * @returns Accessible - */ - public Accessible getAccessibleSelection(int value0) { - return null; // TODO - } // getAccessibleSelection() - - /** - * isAccessibleChildSelected - * @param value0 TODO - * @returns boolean - */ - public boolean isAccessibleChildSelected(int value0) { - return false; // TODO - } // isAccessibleChildSelected() - - /** - * getAccessibleRole - * @returns AccessibleRole - */ - public AccessibleRole getAccessibleRole() { - return AccessibleRole.COMBO_BOX; - } // getAccessibleRole() - - /** - * getAccessibleAction - * @returns AccessibleAction - */ - public AccessibleAction getAccessibleAction() { - return null; // TODO - } // getAccessibleAction() - - /** - * getAccessibleActionDescription - * @param value0 TODO - * @returns String - */ - public String getAccessibleActionDescription(int value0) { - return null; // TODO - } // getAccessibleActionDescription() - - /** - * getAccessibleActionCount - * @returns int - */ - public int getAccessibleActionCount() { - return 0; // TODO - } // getAccessibleActionCount() - - /** - * doAccessibleAction - * @param value0 TODO - * @returns boolean - */ - public boolean doAccessibleAction(int value0) { - return false; // TODO - } // doAccessibleAction() - - /** - * getAccessibleSelectionCount - * @returns int - */ - public int getAccessibleSelectionCount() { - return 0; // TODO - } // getAccessibleSelectionCount() - - /** - * addAccessibleSelection - * @param value0 TODO - */ - public void addAccessibleSelection(int value0) { - // TODO - } // addAccessibleSelection() - - /** - * removeAccessibleSelection - * @param value0 TODO - */ - public void removeAccessibleSelection(int value0) { - // TODO - } // removeAccessibleSelection() - - /** - * clearAccessibleSelection - */ - public void clearAccessibleSelection() { - // TODO - } // clearAccessibleSelection() - - /** - * selectAllAccessibleSelection - */ - public void selectAllAccessibleSelection() { - // TODO - } // selectAllAccessibleSelection() - - - } // AccessibleJComboBox - - /** - * KeySelectionManager - */ - public static interface KeySelectionManager { - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * selectionForKey - * @param value0 TODO - * @param value1 TODO - * @returns int - */ - int selectionForKey(char value0, ComboBoxModel value1); - - - } // KeySelectionManager - - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * uiClassID - */ - private static final String uiClassID = "ComboBoxUI"; - - /** - * dataModel - */ - protected ComboBoxModel dataModel; - - /** - * renderer - */ - protected ListCellRenderer renderer; - - /** - * editor - */ - protected ComboBoxEditor editor; - - /** - * maximumRowCount - */ - protected int maximumRowCount; - - /** - * isEditable - */ - protected boolean isEditable; - - /** - * selectedItemReminder - */ - protected Object selectedItemReminder; - - /** - * keySelectionManager - */ - protected JComboBox.KeySelectionManager keySelectionManager; - - /** - * actionCommand - */ - protected String actionCommand; - - /** - * lightWeightPopupEnabled - */ - protected boolean lightWeightPopupEnabled; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor JComboBox - * @param value0 TODO - */ - public JComboBox(ComboBoxModel value0) { - // TODO - } // JComboBox() - - /** - * Constructor JComboBox - * @param value0 TODO - */ - public JComboBox(Object[] value0) { - // TODO - } // JComboBox() - - /** - * Constructor JComboBox - * @param value0 TODO - */ - public JComboBox(Vector value0) { - // TODO - } // JComboBox() - - /** - * Constructor JComboBox - */ - public JComboBox() { - // TODO - } // JComboBox() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * writeObject - * @param stream TODO - * @exception IOException TODO - */ - private void writeObject(ObjectOutputStream stream) throws IOException { - // TODO - } // writeObject() - - /** - * isEditable - * @returns boolean - */ - public boolean isEditable() { - return false; // TODO - } // isEditable() - - /** - * installAncestorListener - */ - protected void installAncestorListener() { - // TODO - } // installAncestorListener() - - /** - * setUI - * @param ui TODO - */ - public void setUI(ComboBoxUI ui) { - super.setUI(ui); - } // setUI() - - /** - * updateUI - */ - public void updateUI() { - setUI((ComboBoxUI) UIManager.get(this)); - invalidate(); - } // updateUI() - - /** - * getUIClassID - * @returns String - */ - public String getUIClassID() { - return uiClassID; - } // getUIClassID() - - /** - * getUI - * @returns ComboBoxUI - */ - public ComboBoxUI getUI() { - return (ComboBoxUI) ui; - } // getUI() - - /** - * setModel - * @param value0 TODO - */ - public void setModel(ComboBoxModel value0) { - // TODO - } // setModel() - - /** - * getModel - * @returns ComboBoxModel - */ - public ComboBoxModel getModel() { - return null; // TODO - } // getModel() - - /** - * setLightWeightPopupEnabled - * @param value0 TODO - */ - public void setLightWeightPopupEnabled(boolean value0) { - // TODO - } // setLightWeightPopupEnabled() - - /** - * isLightWeightPopupEnabled - * @returns boolean - */ - public boolean isLightWeightPopupEnabled() { - return false; // TODO - } // isLightWeightPopupEnabled() - - /** - * setEditable - * @param value0 TODO - */ - public void setEditable(boolean value0) { - // TODO - } // setEditable() - - /** - * setMaximumRowCount - * @param value0 TODO - */ - public void setMaximumRowCount(int value0) { - // TODO - } // setMaximumRowCount() - - /** - * getMaximumRowCount - * @returns int - */ - public int getMaximumRowCount() { - return 0; // TODO - } // getMaximumRowCount() - - /** - * setRenderer - * @param value0 TODO - */ - public void setRenderer(ListCellRenderer value0) { - // TODO - } // setRenderer() - - /** - * getRenderer - * @returns ListCellRenderer - */ - public ListCellRenderer getRenderer() { - return null; // TODO - } // getRenderer() - - /** - * setEditor - * @param value0 TODO - */ - public void setEditor(ComboBoxEditor value0) { - // TODO - } // setEditor() - - /** - * getEditor - * @returns ComboBoxEditor - */ - public ComboBoxEditor getEditor() { - return null; // TODO - } // getEditor() - - /** - * setSelectedItem - * @param value0 TODO - */ - public void setSelectedItem(Object value0) { - // TODO - } // setSelectedItem() - - /** - * getSelectedItem - * @returns Object - */ - public Object getSelectedItem() { - return null; // TODO - } // getSelectedItem() - - /** - * setSelectedIndex - * @param value0 TODO - */ - public void setSelectedIndex(int value0) { - // TODO - } // setSelectedIndex() - - /** - * getSelectedIndex - * @returns int - */ - public int getSelectedIndex() { - return 0; // TODO - } // getSelectedIndex() - - /** - * addItem - * @param value0 TODO - */ - public void addItem(Object value0) { - // TODO - } // addItem() - - /** - * insertItemAt - * @param value0 TODO - * @param value1 TODO - */ - public void insertItemAt(Object value0, int value1) { - // TODO - } // insertItemAt() - - /** - * removeItem - * @param value0 TODO - */ - public void removeItem(Object value0) { - // TODO - } // removeItem() - - /** - * removeItemAt - * @param value0 TODO - */ - public void removeItemAt(int value0) { - // TODO - } // removeItemAt() - - /** - * removeAllItems - */ - public void removeAllItems() { - // TODO - } // removeAllItems() - - /** - * showPopup - */ - public void showPopup() { - // TODO - } // showPopup() - - /** - * hidePopup - */ - public void hidePopup() { - // TODO - } // hidePopup() - - /** - * setPopupVisible - * @param value0 TODO - */ - public void setPopupVisible(boolean value0) { - // TODO - } // setPopupVisible() - - /** - * isPopupVisible - * @returns boolean - */ - public boolean isPopupVisible() { - return false; // TODO - } // isPopupVisible() - - /** - * setActionCommand - * @param value0 TODO - */ - public void setActionCommand(String value0) { - // TODO - } // setActionCommand() - - /** - * getActionCommand - * @returns String - */ - public String getActionCommand() { - return null; // TODO - } // getActionCommand() - - /** - * setAction - * @param value0 TODO - */ - public void setAction(Action value0) { - // TODO - } // setAction() - - /** - * isListener - * @param value0 TODO - * @param value1 TODO - * @returns boolean - */ - private boolean isListener(Class value0, ActionListener value1) { - return false; // TODO - } // isListener() - - /** - * getAction - * @returns Action - */ - public Action getAction() { - return null; // TODO - } // getAction() - - /** - * configurePropertiesFromAction - * @param value0 TODO - */ - protected void configurePropertiesFromAction(Action value0) { - // TODO - } // configurePropertiesFromAction() - - /** - * createActionPropertyChangeListener - * @param value0 TODO - * @returns PropertyChangeListener - */ - protected PropertyChangeListener createActionPropertyChangeListener(Action value0) { - return null; // TODO - } // createActionPropertyChangeListener() - - /** - * fireItemStateChanged - * @param value0 TODO - */ - protected void fireItemStateChanged(ItemEvent value0) { - // TODO - } // fireItemStateChanged() - - /** - * fireActionEvent - */ - protected void fireActionEvent() { - // TODO - } // fireActionEvent() - - /** - * selectedItemChanged - */ - protected void selectedItemChanged() { - // TODO - } // selectedItemChanged() - - /** - * getSelectedObjects - * @returns Object[] - */ - public Object[] getSelectedObjects() { - return null; // TODO - } // getSelectedObjects() - - /** - * actionPerformed - * @param value0 TODO - */ - public void actionPerformed(ActionEvent value0) { - // TODO - } // actionPerformed() - - /** - * contentsChanged - * @param value0 TODO - */ - public void contentsChanged(ListDataEvent value0) { - // TODO - } // contentsChanged() - - /** - * selectWithKeyChar - * @param value0 TODO - * @returns boolean - */ - public boolean selectWithKeyChar(char value0) { - return false; // TODO - } // selectWithKeyChar() - - /** - * intervalAdded - * @param value0 TODO - */ - public void intervalAdded(ListDataEvent value0) { - // TODO - } // intervalAdded() - - /** - * intervalRemoved - * @param value0 TODO - */ - public void intervalRemoved(ListDataEvent value0) { - // TODO - } // intervalRemoved() - - /** - * setEnabled - * @param value0 TODO - */ - public void setEnabled(boolean value0) { - // TODO - } // setEnabled() - - /** - * configureEditor - * @param value0 TODO - * @param value1 TODO - */ - public void configureEditor(ComboBoxEditor value0, Object value1) { - // TODO - } // configureEditor() - - /** - * processKeyEvent - * @param value0 TODO - */ - public void processKeyEvent(KeyEvent value0) { - // TODO - } // processKeyEvent() - - /** - * isFocusTraversable - * @returns boolean - * @deprecated - */ - public boolean isFocusTraversable() { - return false; // TODO - } // isFocusTraversable() - - /** - * setKeySelectionManager - * @param value0 TODO - */ - public void setKeySelectionManager(KeySelectionManager value0) { - // TODO - } // setKeySelectionManager() - - /** - * getKeySelectionManager - * @returns JComboBox.KeySelectionManager - */ - public JComboBox.KeySelectionManager getKeySelectionManager() { - return null; // TODO - } // getKeySelectionManager() - - /** - * getItemCount - * @returns int - */ - public int getItemCount() { - return 0; // TODO - } // getItemCount() - - /** - * getItemAt - * @param value0 TODO - * @returns Object - */ - public Object getItemAt(int value0) { - return null; // TODO - } // getItemAt() - - /** - * createDefaultKeySelectionManager - * @returns KeySelectionManager - */ - protected KeySelectionManager createDefaultKeySelectionManager() { - return null; // TODO - } // createDefaultKeySelectionManager() - - /** - * paramString - * @returns String - */ - protected String paramString() { - return null; // TODO - } // paramString() - - /** - * getAccessibleContext - * @returns AccessibleContext + /** + * Forces JComboBox to select component located in the given index in the + * combo box. + * + * @param index index specifying location of the component that should be + * selected. + */ + public void setSelectedIndex(int index) + { + // FIXME: if index == -1 then nothing should be selected + setSelectedItem(dataModel.getElementAt(index)); + } + + /** + * Returns index of the item that is currently selected in the combo box. + * If no item is currently selected, then -1 is returned. + * + * @return int index specifying location of the currently selected item in + * the combo box or -1 if nothing is selected in the combo box. + */ + public int getSelectedIndex() + { + Object selectedItem = getSelectedItem(); + if (selectedItem != null && (dataModel instanceof DefaultComboBoxModel)) + return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); + + return -1; + } + + public Object getPrototypeDisplayValue() + { + return prototypeDisplayValue; + } + + public void setPrototypeDisplayValue(Object prototypeDisplayValue) + { + this.prototypeDisplayValue = prototypeDisplayValue; + } + + /** + * This method adds given element to this JComboBox. + * + * @param element element to add + */ + public void addItem(Object element) + { + ((MutableComboBoxModel) dataModel).addElement(element); + } + + /** + * Inserts given element at the specified index to this JComboBox + * + * @param element element to insert + * @param index position where to insert the element + */ + public void insertItemAt(Object element, int index) + { + ((MutableComboBoxModel) dataModel).insertElementAt(element, index); + } + + /** + * This method removes given element from this JComboBox. + * + * @param element element to remove */ + public void removeItem(Object element) + { + ((MutableComboBoxModel) dataModel).removeElement(element); + } + + /** + * This method remove element location in the specified index in the + * JComboBox. + * + * @param index index specifying position of the element to remove + */ + public void removeItemAt(int index) + { + ((MutableComboBoxModel) dataModel).removeElementAt(index); + } + + /** + * This method removes all elements from this JComboBox. + */ + public void removeAllItems() + { + if (dataModel instanceof DefaultComboBoxModel) + ((DefaultComboBoxModel) dataModel).removeAllElements(); + } + + /** + * This method displays popup with list of combo box's items on the screen + */ + public void showPopup() + { + setPopupVisible(true); + } + + /** + * This method hides popup containing list of combo box's items + */ + public void hidePopup() + { + setPopupVisible(false); + } + + /** + * This method either displayes or hides the popup containing list of combo + * box's items. + * + * @param visible show popup if 'visible' is true and hide it otherwise + */ + public void setPopupVisible(boolean visible) + { + getUI().setPopupVisible(this, visible); + } + + /** + * Checks if popup is currently visible on the screen. + * + * @return boolean true if popup is visible and false otherwise + */ + public boolean isPopupVisible() + { + return getUI().isPopupVisible(this); + } + + /** + * This method sets actionCommand to the specified string. ActionEvent fired + * to this JComboBox registered ActionListeners will contain this + * actionCommand. + * + * @param aCommand new action command for the JComboBox's ActionEvent + */ + public void setActionCommand(String aCommand) + { + actionCommand = aCommand; + } + + /** + * Returns actionCommand associated with the ActionEvent fired by the + * JComboBox to its registered ActionListeners. + * + * @return String actionCommand for the ActionEvent + */ + public String getActionCommand() + { + return actionCommand; + } + + /** + * setAction + * + * @param a action to set + */ + public void setAction(Action a) + { + Action old = action; + action = a; + configurePropertiesFromAction(action); + if (action != null) + // FIXME: remove from old action and add to new action + // PropertyChangeListener to listen to changes in the action + addActionListener(action); + } + + /** + * This method returns Action that is invoked when selected item is changed + * in the JComboBox. + * + * @return Action + */ + public Action getAction() + { + return action; + } + + /** + * Configure properties of the JComboBox by reading properties of specified + * action. This method always sets the comboBox's "enabled" property to the + * value of the Action's "enabled" property. + * + * @param a An Action to configure the combo box from + */ + protected void configurePropertiesFromAction(Action a) + { + if (a == null) + { + setEnabled(true); + setToolTipText(null); + } + else + { + setEnabled(a.isEnabled()); + setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); + } + } + + /** + * Creates PropertyChangeListener to listen for the changes in comboBox's + * action properties. + * + * @param action action to listen to for property changes + * + * @return $PropertyChangeListener$ Listener that listens to changes in + * action properties. + */ + protected PropertyChangeListener createActionPropertyChangeListener(Action action) + { + return new PropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent e) + { + Action act = (Action) (e.getSource()); + configurePropertiesFromAction(act); + } + }; + } + + /** + * This method fires ItemEvent to this JComboBox's registered ItemListeners. + * This method is invoked when currently selected item in this combo box + * has changed. + * + * @param e the ItemEvent describing the change in the combo box's + * selection. + */ + protected void fireItemStateChanged(ItemEvent e) + { + ItemListener[] ll = getItemListeners(); + + for (int i = 0; i < ll.length; i++) + ll[i].itemStateChanged(e); + } + + /** + * This method fires ActionEvent to this JComboBox's registered + * ActionListeners. This method is invoked when user explicitly changes + * currently selected item. + */ + protected void fireActionEvent() + { + ActionListener[] ll = getActionListeners(); + + for (int i = 0; i < ll.length; i++) + ll[i].actionPerformed(new ActionEvent(this, + ActionEvent.ACTION_PERFORMED, + actionCommand)); + } + + /** + * This method is invoked whenever selected item changes in the combo box's + * data model. It fires ItemEvent and ActionEvent to all registered + * ComboBox's ItemListeners and ActionListeners respectively, indicating + * the change. + */ + protected void selectedItemChanged() + { + // Fire ItemEvent to indicated that previously selected item is now + // deselected + if (selectedItemReminder != null) + fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, + selectedItemReminder, + ItemEvent.DESELECTED)); + + // Fire ItemEvent to indicate that new item is selected + Object newSelection = getSelectedItem(); + fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, + newSelection, ItemEvent.SELECTED)); + + // Fire Action Event to JComboBox's registered listeners + fireActionEvent(); + + selectedItemReminder = newSelection; + } + + /** + * Returns Object array of size 1 containing currently selected element in + * the JComboBox. + * + * @return Object[] Object array of size 1 containing currently selected + * element in the JComboBox. + */ + public Object[] getSelectedObjects() + { + Object selectedObject = getSelectedItem(); + return new Object[] { selectedObject }; + } + + /** + * This method handles actionEvents fired by the ComboBoxEditor. It changes + * this JComboBox's selection to the new value currently in the editor and + * hides list of combo box items. + * + * @param e the ActionEvent + */ + public void actionPerformed(ActionEvent e) + { + setSelectedItem(((ComboBoxEditor) e.getSource()).getItem()); + setPopupVisible(false); + } + + /** + * This method selects item in this combo box that matches specified + * specified keyChar and returns true if such item is found. Otherwise + * false is returned. + * + * @param keyChar character indicating which item in the combo box should be + * selected. + * + * @return boolean true if item corresponding to the specified keyChar + * exists in the combo box. Otherwise false is returned. + */ + public boolean selectWithKeyChar(char keyChar) + { + // FIXME: Need to implement + return false; + } + + /** + * The part of implementation of ListDataListener interface. This method is + * invoked when some items where added to the JComboBox's data model. + * + * @param event ListDataEvent describing the change + */ + public void intervalAdded(ListDataEvent event) + { + // FIXME: Need to implement + repaint(); + } + + /** + * The part of implementation of ListDataListener interface. This method is + * invoked when some items where removed from the JComboBox's data model. + * + * @param event ListDataEvent describing the change. + */ + public void intervalRemoved(ListDataEvent event) + { + // FIXME: Need to implement + repaint(); + } + + /** + * The part of implementation of ListDataListener interface. This method is + * invoked when contents of the JComboBox's data model changed. + * + * @param event ListDataEvent describing the change + */ + public void contentsChanged(ListDataEvent event) + { + // if first and last index of the given ListDataEvent are both -1, + // then it indicates that selected item in the combo box data model + // have changed. + if (event.getIndex0() == -1 && event.getIndex1() == -1) + selectedItemChanged(); + } + + /** + * This method disables or enables JComboBox. If the JComboBox is enabled, + * then user is able to make item choice, otherwise if JComboBox is + * disabled then user is not able to make a selection. + * + * @param enabled if 'enabled' is true then enable JComboBox and disable it + */ + public void setEnabled(boolean enabled) + { + boolean oldEnabled = super.isEnabled(); + if (enabled != oldEnabled) + { + super.setEnabled(enabled); + firePropertyChange(ENABLED_CHANGED_PROPERTY, oldEnabled, + (boolean) enabled); + } + } + + /** + * This method initializes specified ComboBoxEditor to display given item. + * + * @param anEditor ComboBoxEditor to initialize + * @param anItem Item that should displayed in the specified editor + */ + public void configureEditor(ComboBoxEditor anEditor, Object anItem) + { + anEditor.setItem(anItem); + } + + /** + * This method hides combo box's popup whenever TAB key is pressed. + * + * @param e The KeyEvent indicating which key was pressed. + */ + public void processKeyEvent(KeyEvent e) + { + } + + /** + * This method always returns false to indicate that JComboBox itself is + * not focus traversable. + * + * @return false to indicate that JComboBox itself is not focus traversable. + * + * @deprecated + */ + public boolean isFocusTraversable() + { + return false; + } + + /** + * setKeySelectionManager + * + * @param aManager + */ + public void setKeySelectionManager(KeySelectionManager aManager) + { + } + + /** + * getKeySelectionManager + * + * @return JComboBox.KeySelectionManager + */ + public KeySelectionManager getKeySelectionManager() + { + return null; + } + + /** + * This method returns number of elements in this JComboBox + * + * @return int number of elements in this JComboBox + */ + public int getItemCount() + { + return ((DefaultComboBoxModel) dataModel).getSize(); + } + + /** + * Returns elements located in the combo box at the given index. + * + * @param index index specifying location of the component to return. + * + * @return component in the combo box that is located in the given index. + */ + public Object getItemAt(int index) + { + return ((MutableComboBoxModel) dataModel).getElementAt(index); + } + + /** + * createDefaultKeySelectionManager + * + * @return KeySelectionManager + */ + protected KeySelectionManager createDefaultKeySelectionManager() + { + return null; + } + + /** + * A string that describes this JComboBox. Normally only used for debugging. + * + * @return A string describing this JComboBox + */ + protected String paramString() + { + return "JComboBox"; + } + public AccessibleContext getAccessibleContext() { if (accessibleContext == null) @@ -797,74 +994,180 @@ public class JComboBox extends JComponent return accessibleContext; } - + /** - * addActionListener - * @param listener TODO + * This methods adds specified ActionListener to this JComboBox. + * + * @param listener to add */ - public void addActionListener (ActionListener listener) + public void addActionListener(ActionListener listener) { - listenerList.add (ActionListener.class, listener); + listenerList.add(ActionListener.class, listener); } /** - * removeActionListener - * @param listener TODO + * This method removes specified ActionListener from this JComboBox. + * + * @param listener ActionListener */ - public void removeActionListener (ActionListener listener) + public void removeActionListener(ActionListener listener) { - listenerList.remove (ActionListener.class, listener); + listenerList.remove(ActionListener.class, listener); } /** + * This method returns array of ActionListeners that are registered with + * this JComboBox. + * * @since 1.4 */ public ActionListener[] getActionListeners() { - return (ActionListener[]) getListeners (ActionListener.class); + return (ActionListener[]) getListeners(ActionListener.class); } /** - * addItemListener - * @param listener TODO + * This method registers given ItemListener with this JComboBox + * + * @param listener to remove */ public void addItemListener(ItemListener listener) { - listenerList.add (ItemListener.class, listener); + listenerList.add(ItemListener.class, listener); } /** - * removeItemListener - * @param listener TODO + * This method unregisters given ItemListener from this JComboBox + * + * @param listener to remove */ public void removeItemListener(ItemListener listener) { - listenerList.remove (ItemListener.class, listener); + listenerList.remove(ItemListener.class, listener); } /** + * This method returns array of ItemListeners that are registered with this + * JComboBox. + * * @since 1.4 */ public ItemListener[] getItemListeners() { - return (ItemListener[]) getListeners (ItemListener.class); + return (ItemListener[]) getListeners(ItemListener.class); } - public void addPopupMenuListener (PopupMenuListener listener) + /** + * Adds PopupMenuListener to combo box to listen to the events fired by the + * combo box's popup menu containing its list of items + * + * @param listener to add + */ + public void addPopupMenuListener(PopupMenuListener listener) { - listenerList.add (PopupMenuListener.class, listener); + listenerList.add(PopupMenuListener.class, listener); } - public void removePopupMenuListener (PopupMenuListener listener) + /** + * Removes PopupMenuListener to combo box to listen to the events fired by + * the combo box's popup menu containing its list of items + * + * @param listener to add + */ + public void removePopupMenuListener(PopupMenuListener listener) { - listenerList.remove (PopupMenuListener.class, listener); + listenerList.remove(PopupMenuListener.class, listener); } /** - * @since 1.4 + * Returns array of PopupMenuListeners that are registered with combo box. */ public PopupMenuListener[] getPopupMenuListeners() { - return (PopupMenuListener[]) getListeners (PopupMenuListener.class); + return (PopupMenuListener[]) getListeners(PopupMenuListener.class); + } + + /** + * AccessibleJComboBox + */ + protected class AccessibleJComboBox extends AccessibleJComponent + implements AccessibleAction, AccessibleSelection + { + private static final long serialVersionUID = 8217828307256675666L; + + protected AccessibleJComboBox() + { + } + + public int getAccessibleChildrenCount() + { + return 0; + } + + public Accessible getAccessibleChild(int value0) + { + return null; + } + + public AccessibleSelection getAccessibleSelection() + { + return null; + } + + public Accessible getAccessibleSelection(int value0) + { + return null; + } + + public boolean isAccessibleChildSelected(int value0) + { + return false; + } + + public AccessibleRole getAccessibleRole() + { + return AccessibleRole.COMBO_BOX; + } + + public AccessibleAction getAccessibleAction() + { + return null; + } + + public String getAccessibleActionDescription(int value0) + { + return null; + } + + public int getAccessibleActionCount() + { + return 0; + } + + public boolean doAccessibleAction(int value0) + { + return false; + } + + public int getAccessibleSelectionCount() + { + return 0; + } + + public void addAccessibleSelection(int value0) + { + } + + public void removeAccessibleSelection(int value0) + { + } + + public void clearAccessibleSelection() + { + } + + public void selectAllAccessibleSelection() + { + } } } diff --git a/libjava/javax/swing/JComponent.java b/libjava/javax/swing/JComponent.java index e8f01d028b4..eadf855a3ed 100644 --- a/libjava/javax/swing/JComponent.java +++ b/libjava/javax/swing/JComponent.java @@ -37,6 +37,7 @@ exception statement from your version. */ package javax.swing; +import java.awt.AWTEvent; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -48,11 +49,13 @@ import java.awt.Image; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; +import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; import java.awt.image.ImageObserver; @@ -192,22 +195,12 @@ public abstract class JComponent extends Container implements Serializable Border border; /** - * A tooltip associated with this component. - * - * @see #setToolTip - * @see #getToolTip - * @see #toolTipText - */ - JToolTip toolTip; - - /** - * The text to show in the tooltip associated with this component. + * The text to show in the tooltip associated with this component. * * @see #setToolTipText * @see #getToolTipText - * @see #toolTip */ - String toolTipText; + String toolTipText; /** *

    Whether to double buffer this component when painting. This flag @@ -325,6 +318,11 @@ public abstract class JComponent extends Container implements Serializable * first client property. */ private Hashtable clientProperties; + + private InputMap inputMap_whenFocused; + private InputMap inputMap_whenAncestorOfFocused; + private InputMap inputMap_whenInFocusedWindow; + private ActionMap actionMap; /** * A lock held during recursive painting; this is used to serialize @@ -757,18 +755,6 @@ public abstract class JComponent extends Container implements Serializable return null; } - /** - * Get the ActionListener (typically an {@link Action} object) which is - * associated with a particular keystroke. - * - * @param aKeyStroke The keystroke to retrieve the action of - * - * @return The action associated with the specified keystroke - */ - public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke) - { - return null; - } /** * Get the value of the {@link #alignmentX} property. @@ -875,24 +861,6 @@ public abstract class JComponent extends Container implements Serializable return g; } - /** - * Return the condition that determines whether a registered action - * occurs in response to the specified keystroke. - * - * @param aKeyStroke The keystroke to return the condition of - * - * @return One of the values {@link #UNDEFINED_CONDITION}, {@link - * #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link - * #WHEN_IN_FOCUSED_WINDOW} - * - * @see #registerKeyboardAction - * @see #unregisterKeyboardAction - * @see #resetKeyboardActiond - */ - public int getConditionForKeyStroke(KeyStroke aKeyStroke) - { - return UNDEFINED_CONDITION; - } /** * Get the value of the {@link #debugGraphicsOptions} property. @@ -1113,11 +1081,9 @@ public abstract class JComponent extends Container implements Serializable */ public JToolTip createToolTip() { - if (toolTip == null) - { - toolTip = new JToolTip(); + JToolTip toolTip = new JToolTip(); + toolTip.setComponent(this); toolTip.setTipText(toolTipText); - } return toolTip; } @@ -1145,7 +1111,22 @@ public abstract class JComponent extends Container implements Serializable */ public void setToolTipText(String text) { + if (text == null) + { + ToolTipManager.sharedInstance().unregisterComponent(this); + toolTipText = null; + return; + } + + // XXX: The tip text doesn't get updated unless you set it to null + // and then to something not-null. This is consistent with the behaviour + // of Sun's ToolTipManager. + + String oldText = toolTipText; toolTipText = text; + + if (oldText == null) + ToolTipManager.sharedInstance().registerComponent(this); } /** @@ -1172,7 +1153,7 @@ public abstract class JComponent extends Container implements Serializable */ public String getToolTipText(MouseEvent event) { - return toolTipText; + return getToolTipText(); } /** @@ -1519,6 +1500,51 @@ public abstract class JComponent extends Container implements Serializable registerKeyboardAction(act, null, stroke, cond); } + /* + * There is some charmingly undocumented behavior sun seems to be using + * to simulate the old register/unregister keyboard binding API. It's not + * clear to me why this matters, but we shall endeavour to follow suit. + * + * Two main thing seem to be happening when you do registerKeyboardAction(): + * + * - no actionMap() entry gets created, just an entry in inputMap() + * + * - the inputMap() entry is a proxy class which invokes the the + * binding's actionListener as a target, and which clobbers the command + * name sent in the ActionEvent, providing the binding command name + * instead. + * + * This much you can work out just by asking the input and action maps + * what they contain after making bindings, and watching the event which + * gets delivered to the recipient. Beyond that, it seems to be a + * sun-private solution so I will only immitate it as much as it matters + * to external observers. + */ + + private static class ActionListenerProxy + extends AbstractAction + { + ActionListener target; + String bindingCommandName; + + public ActionListenerProxy(ActionListener li, + String cmd) + { + target = li; + bindingCommandName = cmd; + } + + public void actionPerformed(ActionEvent e) + { + ActionEvent derivedEvent = new ActionEvent(e.getSource(), + e.getID(), + bindingCommandName, + e.getModifiers()); + target.actionPerformed(derivedEvent); + } + } + + /** * An obsolete method to register a keyboard action on this component. * You should use getInputMap and getActionMap @@ -1543,8 +1569,185 @@ public abstract class JComponent extends Container implements Serializable KeyStroke stroke, int cond) { + getInputMap(cond).put(stroke, new ActionListenerProxy(act, cmd)); + } + + + + public final void setInputMap(int condition, InputMap map) + { + enableEvents(AWTEvent.KEY_EVENT_MASK); + switch (condition) + { + case WHEN_FOCUSED: + inputMap_whenFocused = map; + break; + + case WHEN_ANCESTOR_OF_FOCUSED_COMPONENT: + inputMap_whenAncestorOfFocused = map; + break; + + case WHEN_IN_FOCUSED_WINDOW: + inputMap_whenInFocusedWindow = map; + break; + + case UNDEFINED_CONDITION: + default: + throw new IllegalArgumentException(); + } + } + + public final InputMap getInputMap(int condition) + { + enableEvents(AWTEvent.KEY_EVENT_MASK); + switch (condition) + { + case WHEN_FOCUSED: + if (inputMap_whenFocused == null) + inputMap_whenFocused = new InputMap(); + return inputMap_whenFocused; + + case WHEN_ANCESTOR_OF_FOCUSED_COMPONENT: + if (inputMap_whenAncestorOfFocused == null) + inputMap_whenAncestorOfFocused = new InputMap(); + return inputMap_whenAncestorOfFocused; + + case WHEN_IN_FOCUSED_WINDOW: + if (inputMap_whenInFocusedWindow == null) + inputMap_whenInFocusedWindow = new InputMap(); + return inputMap_whenInFocusedWindow; + + case UNDEFINED_CONDITION: + default: + return null; + } + } + + public final InputMap getInputMap() + { + return getInputMap(WHEN_FOCUSED); + } + + public final ActionMap getActionMap() + { + if (actionMap == null) + actionMap = new ActionMap(); + return actionMap; + } + + public final void setActionMap(ActionMap map) + { + actionMap = map; } + /** + * @deprecated As of 1.3 KeyStrokes can be registered with multiple + * simultaneous conditions. + * + * Return the condition that determines whether a registered action + * occurs in response to the specified keystroke. + * + * @param aKeyStroke The keystroke to return the condition of + * + * @return One of the values {@link #UNDEFINED_CONDITION}, {@link + * #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link + * #WHEN_IN_FOCUSED_WINDOW} + * + * @see #registerKeyboardAction + * @see #unregisterKeyboardAction + * @see #resetKeyboardActiond + */ + public int getConditionForKeyStroke(KeyStroke ks) + { + if (inputMap_whenFocused != null + && inputMap_whenFocused.get(ks) != null) + return WHEN_FOCUSED; + else if (inputMap_whenAncestorOfFocused != null + && inputMap_whenAncestorOfFocused.get(ks) != null) + return WHEN_ANCESTOR_OF_FOCUSED_COMPONENT; + else if (inputMap_whenInFocusedWindow != null + && inputMap_whenInFocusedWindow.get(ks) != null) + return WHEN_IN_FOCUSED_WINDOW; + else + return UNDEFINED_CONDITION; + } + + /** + * @deprecated Use {@link #getActionMap()} + * + * Get the ActionListener (typically an {@link Action} object) which is + * associated with a particular keystroke. + * + * @param aKeyStroke The keystroke to retrieve the action of + * + * @return The action associated with the specified keystroke + */ + public ActionListener getActionForKeyStroke(KeyStroke ks) + { + Object cmd = getInputMap().get(ks); + if (cmd != null) + { + if (cmd instanceof ActionListenerProxy) + return (ActionListenerProxy) cmd; + else if (cmd instanceof String) + return getActionMap().get(cmd); + } + return null; + } + + /** + * A hook for subclasses which want to customize event processing. + */ + protected void processComponentKeyEvent(KeyEvent e) + { + } + + /** + * Override the default key dispatch system from Component to hook into + * the swing {@link InputMap} / {@link ActionMap} system. + * + * See this + * report for more details, it's somewhat complex. + */ + protected void processKeyEvent(KeyEvent e) + { + processComponentKeyEvent(e); + + // FIXME: this needs to be elaborated significantly, to do all the + // focus / ancestor / window searching for the various binding modes. + if (! e.isConsumed() && + processKeyBinding(KeyStroke.getKeyStrokeForEvent(e), + e, WHEN_FOCUSED, e.getID() == KeyEvent.KEY_PRESSED)) + e.consume(); + } + + protected boolean processKeyBinding(KeyStroke ks, + KeyEvent e, + int condition, + boolean pressed) + { + if (isEnabled()) + { + Action act = null; + InputMap map = getInputMap(condition); + if (map != null) + { + Object cmd = map.get(ks); + if (cmd != null) + { + if (cmd instanceof ActionListenerProxy) + act = (Action) cmd; + else + act = (Action) getActionMap().get(cmd); + } + } + if (act != null && act.isEnabled()) + return SwingUtilities.notifyAction(act, ks, e, this, e.getModifiers()); + } + return false; + } + /** * Remove a keyboard action registry. * @@ -1568,6 +1771,14 @@ public abstract class JComponent extends Container implements Serializable */ public void resetKeyboardActions() { + if (inputMap_whenFocused != null) + inputMap_whenFocused.clear(); + if (inputMap_whenAncestorOfFocused != null) + inputMap_whenAncestorOfFocused.clear(); + if (inputMap_whenInFocusedWindow != null) + inputMap_whenInFocusedWindow.clear(); + if (actionMap != null) + actionMap.clear(); } @@ -1875,11 +2086,14 @@ public abstract class JComponent extends Container implements Serializable if (ui != null) ui.uninstallUI(this); + ComponentUI oldUI = ui; ui = newUI; if (ui != null) ui.installUI(this); + firePropertyChange("UI", oldUI, newUI); + revalidate(); repaint(); } diff --git a/libjava/javax/swing/JFormattedTextField.java b/libjava/javax/swing/JFormattedTextField.java index b84d7cc0de3..8074799a7ab 100644 --- a/libjava/javax/swing/JFormattedTextField.java +++ b/libjava/javax/swing/JFormattedTextField.java @@ -135,7 +135,7 @@ public class JFormattedTextField extends JTextField public JFormattedTextField () { - throw new InternalError ("not implemented"); + this((AbstractFormatterFactory) null); } public JFormattedTextField (Format format) @@ -150,7 +150,7 @@ public class JFormattedTextField extends JTextField public JFormattedTextField (AbstractFormatterFactory factory) { - throw new InternalError ("not implemented"); + this(factory, null); } public JFormattedTextField (AbstractFormatterFactory factory, Object value) diff --git a/libjava/javax/swing/JLabel.java b/libjava/javax/swing/JLabel.java index 0a15cfc9c5f..652c965e545 100644 --- a/libjava/javax/swing/JLabel.java +++ b/libjava/javax/swing/JLabel.java @@ -38,8 +38,9 @@ exception statement from your version. */ package javax.swing; import java.awt.Component; -import java.awt.Image; import java.awt.Font; +import java.awt.Image; +import java.awt.event.KeyEvent; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.swing.Icon; @@ -48,7 +49,7 @@ import javax.swing.plaf.LabelUI; /** *

    - * A swing widget that displays a text message and/or an icon. + * A swing widget that displays a text message and/or an icon. *

    */ public class JLabel extends JComponent implements Accessible, SwingConstants @@ -63,10 +64,10 @@ public class JLabel extends JComponent implements Accessible, SwingConstants protected Component labelFor; /** The label's text. */ - private transient String labelText; + private transient String text; /** Where the label will be positioned horizontally. */ - private transient int horizontalAlignment = CENTER; + private transient int horizontalAlignment = LEADING; /** Where the label text will be placed horizontally relative to the icon. */ private transient int horizontalTextPosition = TRAILING; @@ -78,16 +79,16 @@ public class JLabel extends JComponent implements Accessible, SwingConstants private transient int verticalTextPosition = CENTER; /** The icon painted when the label is enabled. */ - private transient Icon activeIcon; + private transient Icon icon; /** The icon painted when the label is disabled. */ private transient Icon disabledIcon; /** The label's mnemnonic key. */ - private transient char mnemonicKey; + private transient int displayedMnemonic = KeyEvent.VK_UNDEFINED; /** The index of the menemonic character in the text. */ - private transient int underlinedChar = -1; + private transient int displayedMnemonicIndex = -1; /** The gap between the icon and the text. */ private transient int iconTextGap = 4; @@ -102,10 +103,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * changes. */ public static final String DISPLAYED_MNEMONIC_CHANGED_PROPERTY = "displayedMnemonic"; - + /** - * Fired in a PropertyChangeEvent when the "displayedMnemonicIndex" - * property changes. */ + * Fired in a PropertyChangeEvent when the "displayedMnemonicIndex" property + * changes. + */ public static final String DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY = "displayedMnemonicIndex"; /** @@ -145,8 +147,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition"; /** - * Creates a new horizontally and vertically centered JLabel object with no text and no - * icon. + * Creates a new horizontally and vertically centered JLabel object with no + * text and no icon. */ public JLabel() { @@ -154,8 +156,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants } /** - * Creates a new horizontally and vertically centered JLabel object with no text and the - * given icon. + * Creates a new horizontally and vertically centered JLabel object with no + * text and the given icon. * * @param image The icon to use with the label. */ @@ -165,8 +167,9 @@ public class JLabel extends JComponent implements Accessible, SwingConstants } /** - * Creates a new vertically centered JLabel object with no text and the given icon and - * horizontal alignment. By default, the text is TRAILING the image. + * Creates a new vertically centered JLabel object with no text and the + * given icon and horizontal alignment. By default, the text is TRAILING + * the image. * * @param image The icon to use with the label. * @param horizontalAlignment The horizontal alignment of the label. @@ -177,8 +180,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants } /** - * Creates a new horizontally and vertically centered JLabel object with no icon and the - * given text. + * Creates a new horizontally and vertically centered JLabel object with no + * icon and the given text. * * @param text The text to use with the label. */ @@ -188,8 +191,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants } /** - * Creates a new vertically centered JLabel object with no icon and the given text and - * horizontal alignment. + * Creates a new vertically centered JLabel object with no icon and the + * given text and horizontal alignment. * * @param text The text to use with the label. * @param horizontalAlignment The horizontal alignment of the label. @@ -200,8 +203,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants } /** - * Creates a new vertically centered JLabel object with the given text, icon, and horizontal - * alignment. + * Creates a new vertically centered JLabel object with the given text, + * icon, and horizontal alignment. * * @param text The text to use with the label. * @param icon The icon to use with the label. @@ -209,8 +212,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants */ public JLabel(String text, Icon icon, int horizontalAlignment) { - labelText = text; - activeIcon = icon; + this.text = text; + this.icon = icon; this.horizontalAlignment = horizontalAlignment; updateUI(); } @@ -273,24 +276,25 @@ public class JLabel extends JComponent implements Accessible, SwingConstants */ public String getText() { - return labelText; + return text; } /** * This method changes the "text" property. The given text will be painted * in the label. * - * @param text The label's text. + * @param newText The label's text. */ - public void setText(String text) + public void setText(String newText) { - if (text != labelText) + if (text != newText) { - String oldText = labelText; - labelText = text; - firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, labelText); - if (labelText != null && labelText.length() <= underlinedChar) - setDisplayedMnemonicIndex(labelText.length() - 1); + String oldText = text; + text = newText; + firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, newText); + + if (text != null && text.length() <= displayedMnemonicIndex) + setDisplayedMnemonicIndex(text.length() - 1); } } @@ -302,37 +306,39 @@ public class JLabel extends JComponent implements Accessible, SwingConstants */ public Icon getIcon() { - return activeIcon; + return icon; } /** * This method changes the "icon" property. This icon (the active icon) will * be the one displayed when the label is enabled. * - * @param icon The active icon. + * @param newIcon The active icon. */ - public void setIcon(Icon icon) + public void setIcon(Icon newIcon) { - if (icon != activeIcon) + if (icon != newIcon) { - Icon oldIcon = activeIcon; - activeIcon = icon; - firePropertyChange(ICON_CHANGED_PROPERTY, oldIcon, activeIcon); + Icon oldIcon = icon; + icon = newIcon; + firePropertyChange(ICON_CHANGED_PROPERTY, oldIcon, newIcon); } } /** * This method returns the disabled icon. The disabled icon is painted when - * the label is disabled. If the disabled icon is null and the active icon is - * an ImageIcon, this method returns a grayed version of the icon. The grayed - * version of the icon becomes the disabledIcon. + * the label is disabled. If the disabled icon is null and the active icon + * is an ImageIcon, this method returns a grayed version of the icon. The + * grayed version of the icon becomes the disabledIcon. * * @return The disabled icon. */ public Icon getDisabledIcon() { - if (disabledIcon == null && activeIcon instanceof ImageIcon) - disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) activeIcon).getImage())); + if (disabledIcon == null && icon instanceof ImageIcon) + disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon) + .getImage())); + return disabledIcon; } @@ -340,16 +346,15 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * This method changes the "disabledIcon" property. This icon (the disabled * icon) will be the one displayed when the label is disabled. * - * @param disabledIcon The disabled icon. + * @param newIcon The disabled icon. */ - public void setDisabledIcon(Icon disabledIcon) + public void setDisabledIcon(Icon newIcon) { - if (disabledIcon != this.disabledIcon) + if (disabledIcon != newIcon) { - Icon oldDisabledIcon = this.disabledIcon; - this.disabledIcon = disabledIcon; - firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldDisabledIcon, - this.disabledIcon); + Icon oldIcon = disabledIcon; + disabledIcon = newIcon; + firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldIcon, newIcon); } } @@ -358,11 +363,19 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * label is used as a label for another component, the label will give * focus to that component when the mnemonic is activated. * - * @param key The keycode to use for the mnemonic. + * @param mnemonic The keycode to use for the mnemonic. */ - public void setDisplayedMnemonic(int key) + public void setDisplayedMnemonic(int mnemonic) { - setDisplayedMnemonic((char) key); + if (displayedMnemonic != mnemonic) + { + firePropertyChange(DISPLAYED_MNEMONIC_CHANGED_PROPERTY, + displayedMnemonic, mnemonic); + displayedMnemonic = mnemonic; + + if (text != null) + setDisplayedMnemonicIndex(text.indexOf(mnemonic)); + } } /** @@ -370,19 +383,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * label is used as a label for another component, the label will give * focus to that component when the mnemonic is activated. * - * @param aChar The character to use for the mnemonic. + * @param mnemonic The character to use for the mnemonic. */ - public void setDisplayedMnemonic(char aChar) + public void setDisplayedMnemonic(char mnemonic) { - if (aChar != mnemonicKey) - { - char oldKey = mnemonicKey; - mnemonicKey = aChar; - firePropertyChange(DISPLAYED_MNEMONIC_CHANGED_PROPERTY, oldKey, - mnemonicKey); - if (labelText != null) - setDisplayedMnemonicIndex(labelText.indexOf(mnemonicKey)); - } + setDisplayedMnemonic((int) mnemonic); } /** @@ -392,7 +397,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants */ public int getDisplayedMnemonic() { - return (int) mnemonicKey; + return (int) displayedMnemonic; } /** @@ -401,27 +406,26 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * no mnemonic. If the index is less than -1 or if the index is equal to * the length, this method will throw an IllegalArgumentException. * - * @param index The index of the character to underline. + * @param newIndex The index of the character to underline. * * @throws IllegalArgumentException If index less than -1 or index equals * length. */ - public void setDisplayedMnemonicIndex(int index) + public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { - if (index < -1 || labelText != null && index >= labelText.length()) + if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); - - if (labelText == null || labelText.charAt(index) != mnemonicKey) - index = -1; - - if (index != underlinedChar) - { - int oldIndex = underlinedChar; - underlinedChar = index; - firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY, - oldIndex, underlinedChar); - } + + if (text == null || text.charAt(newIndex) != displayedMnemonic) + newIndex = -1; + + if (newIndex != displayedMnemonicIndex) + { + firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY, + displayedMnemonicIndex, newIndex); + displayedMnemonicIndex = newIndex; + } } /** @@ -432,7 +436,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants */ public int getDisplayedMnemonicIndex() { - return underlinedChar; + return displayedMnemonicIndex; } /** @@ -490,16 +494,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants * This method changes the "iconTextGap" property. The iconTextGap * determines how much space there is between the icon and the text. * - * @param iconTextGap The gap between the icon and the text. + * @param newGap The gap between the icon and the text. */ - public void setIconTextGap(int iconTextGap) + public void setIconTextGap(int newGap) { - if (iconTextGap != this.iconTextGap) + if (iconTextGap != newGap) { - int oldIconTextGap = this.iconTextGap; - this.iconTextGap = iconTextGap; - firePropertyChange(ICON_TEXT_GAP_CHANGED_PROPERTY, oldIconTextGap, - iconTextGap); + firePropertyChange(ICON_TEXT_GAP_CHANGED_PROPERTY, iconTextGap, newGap); + iconTextGap = newGap; } } @@ -632,11 +634,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) { - Icon currIcon = (isEnabled()) ? activeIcon : disabledIcon; + Icon currIcon = isEnabled() ? icon : disabledIcon; - //Is this the correct way to check for image equality? + // XXX: Is this the correct way to check for image equality? if (currIcon != null && currIcon instanceof ImageIcon) return (((ImageIcon) currIcon).getImage() == img); + return false; } @@ -664,15 +667,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants { if (c != labelFor) { - Component oldLabelFor = labelFor; + firePropertyChange(LABEL_FOR_CHANGED_PROPERTY, labelFor, c); labelFor = c; - firePropertyChange(LABEL_FOR_CHANGED_PROPERTY, oldLabelFor, labelFor); } } - + /** - * This method overrides setFont so that we can call for a repaint - * after the font is changed. + * This method overrides setFont so that we can call for a repaint after the + * font is changed. * * @param f The font for this label. */ diff --git a/libjava/javax/swing/JLayeredPane.java b/libjava/javax/swing/JLayeredPane.java index 78ff95e0b76..a184e215a73 100644 --- a/libjava/javax/swing/JLayeredPane.java +++ b/libjava/javax/swing/JLayeredPane.java @@ -153,7 +153,7 @@ public class JLayeredPane extends JComponent implements Accessible Map.Entry pair = (Map.Entry) i.next(); Integer layerNum = (Integer) pair.getKey (); Integer layerSz = (Integer) pair.getValue (); - if (layerNum == layer) + if (layerNum.intValue() == layer.intValue()) { ret[0] = ret[1] - layerSz.intValue (); return ret; @@ -314,7 +314,7 @@ public class JLayeredPane extends JComponent implements Accessible int bot = range[1]; if (position == -1) position = (bot - top) - 1; - int targ = top + position; + int targ = Math.min(top + position, bot-1); int curr = -1; Component[] comps = getComponents(); @@ -539,7 +539,8 @@ public class JLayeredPane extends JComponent implements Accessible int layer, int position) { - componentToLayer.put (c, getObjectForLayer (layer)); + remove(c); + add(c, getObjectForLayer (layer)); setPosition(c, position); revalidate(); repaint(); diff --git a/libjava/javax/swing/JList.java b/libjava/javax/swing/JList.java index 937d41cceac..b7638810c0b 100644 --- a/libjava/javax/swing/JList.java +++ b/libjava/javax/swing/JList.java @@ -588,6 +588,28 @@ public class JList extends JComponent implements Accessible, Scrollable return getUI().locationToIndex(this, r.getLocation()); } + + /** + * Returns index of the cell to which specified location is closest to + * @param location for which to look for in the list + * + * @return index of the cell to which specified location is closest to. + */ + public int locationToIndex(Point location) { + return getUI().locationToIndex(this, location); + } + + /** + * Returns location of the cell located at the specified index in the list. + * @param index of the cell for which location will be determined + * + * @return location of the cell located at the specified index in the list. + */ + public Point indexToLocation(int index){ + //FIXME: Need to implement. + return null; + } + /** * Returns the list index of the lower right or lower left corner of the * {@link #visibleRect} property, depending on the {@link diff --git a/libjava/javax/swing/JMenuItem.java b/libjava/javax/swing/JMenuItem.java index b137271715d..6bf2abc0556 100644 --- a/libjava/javax/swing/JMenuItem.java +++ b/libjava/javax/swing/JMenuItem.java @@ -313,7 +313,8 @@ public class JMenuItem extends AbstractButton implements Accessible, MenuSelectionManager manager) { // Fire MenuDragMouseEvents if mouse is being dragged. - boolean dragged = (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0; + boolean dragged + = (event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0; if (dragged) processMenuDragMouseEvent(createMenuDragMouseEvent(event, path, manager)); @@ -335,11 +336,11 @@ public class JMenuItem extends AbstractButton implements Accessible, setArmed(false); break; case MouseEvent.MOUSE_PRESSED: - if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) - { - model.setArmed(true); - model.setPressed(true); - } + if ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) + { + model.setArmed(true); + model.setPressed(true); + } break; case MouseEvent.MOUSE_RELEASED: break; @@ -588,6 +589,18 @@ public class JMenuItem extends AbstractButton implements Accessible, listenerList.remove(MenuDragMouseListener.class, listener); } + /** + * Returns all added MenuDragMouseListener objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public MenuDragMouseListener[] getMenuDragMouseListeners() + { + return (MenuDragMouseListener[]) listenerList.getListeners(MenuDragMouseListener.class); + } + /** * Adds an MenuKeyListener to this menu item. This listener will be * invoked when MenuKeyEvents will be fired by this menu item. @@ -609,6 +622,18 @@ public class JMenuItem extends AbstractButton implements Accessible, listenerList.remove(MenuKeyListener.class, listener); } + /** + * Returns all added MenuKeyListener objects. + * + * @return an array of listeners + * + * @since 1.4 + */ + public MenuKeyListener[] getMenuKeyListeners() + { + return (MenuKeyListener[]) listenerList.getListeners(MenuKeyListener.class); + } + /** * A string that describes this JMenuItem. Normally only used * for debugging. diff --git a/libjava/javax/swing/JPopupMenu.java b/libjava/javax/swing/JPopupMenu.java index 9c06400de10..d7d3e43f86f 100644 --- a/libjava/javax/swing/JPopupMenu.java +++ b/libjava/javax/swing/JPopupMenu.java @@ -144,6 +144,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement /* Location of the popup */ private Point popupLocation; + /* Field indicating if popup menu is visible or not */ + private boolean visible = false; + /* Bound Property indicating visibility of the popup menu*/ public static final String VISIBLE_CHANGED_PROPERTY = "visible"; @@ -564,7 +567,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement */ public boolean isVisible() { - return super.isVisible(); + return visible; } /** @@ -577,7 +580,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement public void setVisible(boolean visible) { boolean old = isVisible(); - super.setVisible(visible); + this.visible = visible; if (old != isVisible()) { firePropertyChange(VISIBLE_CHANGED_PROPERTY, old, (boolean) isVisible()); @@ -615,7 +618,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement .getLayeredPane(); Point p = new Point(popupLocation.x, popupLocation.y); SwingUtilities.convertPointFromScreen(p, layeredPane); - popup.show(p.x, p.y, size.width, size.height); + popup.show(p.x, p.y, size.width, size.height); } else { diff --git a/libjava/javax/swing/JRadioButton.java b/libjava/javax/swing/JRadioButton.java index 21e545eddd4..b1f733acf9e 100644 --- a/libjava/javax/swing/JRadioButton.java +++ b/libjava/javax/swing/JRadioButton.java @@ -44,33 +44,47 @@ public class JRadioButton extends JToggleButton { private static final long serialVersionUID = 7751949583255506856L; - public JRadioButton() - { - this(null, null); - } - public JRadioButton(Action a) - { - this(); - setAction(a); - } - - public JRadioButton(Icon icon) - { - this(null, icon); - } + public JRadioButton() + { + this(null, null); + } + + public JRadioButton(Action a) + { + this(); + setAction(a); + } + + public JRadioButton(Icon icon) + { + this(null, icon); + } - public JRadioButton(String text) - { - this(text, null); - } + public JRadioButton(Icon icon, boolean selected) + { + this(null, icon, selected); + } + + public JRadioButton(String text) + { + this(text, null); + } + + public JRadioButton(String text, boolean selected) + { + this(text, null, selected); + } - public JRadioButton(String text, Icon icon) - { - super(text, icon); - borderPainted = false; - contentAreaFilled = false; - } - + public JRadioButton(String text, Icon icon) + { + super(text, icon); + borderPainted = false; + contentAreaFilled = false; + } + + public JRadioButton(String text, Icon icon, boolean selected) + { + } public AccessibleContext getAccessibleContext() { diff --git a/libjava/javax/swing/JScrollPane.java b/libjava/javax/swing/JScrollPane.java index 8ccee7a1763..798c48b4b72 100644 --- a/libjava/javax/swing/JScrollPane.java +++ b/libjava/javax/swing/JScrollPane.java @@ -41,7 +41,6 @@ package javax.swing; import java.awt.Component; import java.awt.ComponentOrientation; import java.awt.Dimension; -import java.awt.LayoutManager; import java.awt.Insets; import java.awt.LayoutManager; import java.awt.Point; @@ -510,7 +509,8 @@ public class JScrollPane else { // otherwise we got a change update from either the VSB or - // HSB model, and we need to update the viewport position to + // HSB model, and we need to update the viewport positions of + // both the main viewport and any row or column headers to // match. int xpos = 0; @@ -527,6 +527,20 @@ public class JScrollPane if (vp != null && vp.getViewPosition() != pt) vp.setViewPosition(pt); + + pt.x = 0; + + if (rowHeader != null + && rowHeader.getViewPosition() != pt) + rowHeader.setViewPosition(pt); + + pt.x = xpos; + pt.y = 0; + + if (columnHeader != null + && columnHeader.getViewPosition() != pt) + columnHeader.setViewPosition(pt); + } } }; diff --git a/libjava/javax/swing/JTabbedPane.java b/libjava/javax/swing/JTabbedPane.java index efe1abecc7e..0f3fbce8b70 100644 --- a/libjava/javax/swing/JTabbedPane.java +++ b/libjava/javax/swing/JTabbedPane.java @@ -44,7 +44,6 @@ import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.io.Serializable; import java.util.Vector; - import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -79,12 +78,11 @@ public class JTabbedPane extends JComponent implements Serializable, protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent implements AccessibleSelection, ChangeListener { + /** DOCUMENT ME! */ private static final long serialVersionUID = 7610530885966830483L; - + /** * Creates a new AccessibleJTabbedPane object. - * - * @param c DOCUMENT ME! */ public AccessibleJTabbedPane() { @@ -226,12 +224,16 @@ public class JTabbedPane extends JComponent implements Serializable, */ protected class ModelListener implements ChangeListener, Serializable { + /** DOCUMENT ME! */ private static final long serialVersionUID = 497359819958114132L; + /** + * Creates a new ModelListener object. + */ protected ModelListener() { } - + /** * This method is called whenever the model is changed. * @@ -387,7 +389,8 @@ public class JTabbedPane extends JComponent implements Serializable, return title; } - private static final long serialVersionUID = 1614381073220130939L; + /** DOCUMENT ME! */ + private static final long serialVersionUID = 1614381073220130939L; /** * This method sets the title of the tab. @@ -398,7 +401,7 @@ public class JTabbedPane extends JComponent implements Serializable, { title = text; if (title != null && title.length() <= underlinedChar) - setDisplayedMnemonicIndex(title.length() - 1); + setDisplayedMnemonicIndex(title.length() - 1); } /** @@ -817,16 +820,21 @@ public class JTabbedPane extends JComponent implements Serializable, * This method checks the index. * * @param index The index to check. + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * + * @throws IndexOutOfBoundsException DOCUMENT ME! */ private void checkIndex(int index, int start, int end) { if (index < start || index >= end) - throw new IndexOutOfBoundsException("Index < " + start + " || Index >= " + end); + throw new IndexOutOfBoundsException("Index < " + start + " || Index >= " + + end); } /** - * This method sets the selected index. This method - * will hide the old component and show the new component. + * This method sets the selected index. This method will hide the old + * component and show the new component. * * @param index The index to set it at. */ @@ -839,7 +847,7 @@ public class JTabbedPane extends JComponent implements Serializable, getSelectedComponent().hide(); if (index != -1 && getComponentAt(index) != null) getComponentAt(index).show(); - model.setSelectedIndex(index); + model.setSelectedIndex(index); } } @@ -867,8 +875,8 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method inserts tabs into JTabbedPane. This includes - * adding the component to the JTabbedPane and hiding it. + * This method inserts tabs into JTabbedPane. This includes adding the + * component to the JTabbedPane and hiding it. * * @param title The title of the tab. * @param icon The tab's icon. @@ -885,11 +893,11 @@ public class JTabbedPane extends JComponent implements Serializable, // Hide the component so we don't see it. Do it before we parent it // so we don't trigger a repaint. if (component != null) - { - component.hide(); - super.add(component); - } - + { + component.hide(); + super.add(component); + } + if (getSelectedIndex() == -1) setSelectedIndex(0); @@ -934,15 +942,14 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method adds a tab to the JTabbedPane. - * The title of the tab is the Component's name. - * If the Component is an instance of UIResource, it doesn't - * add the tab and instead add the component directly to the + * This method adds a tab to the JTabbedPane. The title of the tab is the + * Component's name. If the Component is an instance of UIResource, it + * doesn't add the tab and instead add the component directly to the * JTabbedPane. * * @param component The associated component. * - * @return The Component that was added. + * @return The Component that was added. */ public Component add(Component component) { @@ -954,17 +961,16 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method adds a tab to the JTabbedPane. - * If the Component is an instance of UIResource, it doesn't - * add the tab and instead add the component directly to the - * JTabbedPane. + * This method adds a tab to the JTabbedPane. If the Component is an + * instance of UIResource, it doesn't add the tab and instead add the + * component directly to the JTabbedPane. * * @param title The title of the tab. * @param component The associated component. * * @return The Component that was added. */ - public Component add(String title, Component component) + public Component add(String title, Component component) { if (component instanceof UIResource) super.add(component); @@ -974,10 +980,9 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method adds a tab to the JTabbedPane. - * If the Component is an instance of UIResource, it doesn't - * add the tab and instead add the component directly to the - * JTabbedPane. + * This method adds a tab to the JTabbedPane. If the Component is an + * instance of UIResource, it doesn't add the tab and instead add the + * component directly to the JTabbedPane. * * @param component The associated component. * @param index The index to insert the tab at. @@ -994,12 +999,11 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method adds a tab to the JTabbedPane. - * If the Component is an instance of UIResource, it doesn't - * add the tab and instead add the component directly to the - * JTabbedPane. If the constraints object is an icon, it - * will be used as the tab's icon. If the constraints object - * is a string, we will use it as the title. + * This method adds a tab to the JTabbedPane. If the Component is an + * instance of UIResource, it doesn't add the tab and instead add the + * component directly to the JTabbedPane. If the constraints object is an + * icon, it will be used as the tab's icon. If the constraints object is a + * string, we will use it as the title. * * @param component The associated component. * @param constraints The constraints object. @@ -1010,12 +1014,11 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method adds a tab to the JTabbedPane. - * If the Component is an instance of UIResource, it doesn't - * add the tab and instead add the component directly to the - * JTabbedPane. If the constraints object is an icon, it - * will be used as the tab's icon. If the constraints object - * is a string, we will use it as the title. + * This method adds a tab to the JTabbedPane. If the Component is an + * instance of UIResource, it doesn't add the tab and instead add the + * component directly to the JTabbedPane. If the constraints object is an + * icon, it will be used as the tab's icon. If the constraints object is a + * string, we will use it as the title. * * @param component The associated component. * @param constraints The constraints object. @@ -1037,27 +1040,25 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * The tab and it's associated component are removed. After - * the component has been removed from the JTabbedPane, it's - * set visible to ensure that it can be seen. + * The tab and it's associated component are removed. After the component + * has been removed from the JTabbedPane, it's set visible to ensure that + * it can be seen. * * @param index The index of the tab to remove. - * - * @throws IndexOutOfBoundsException If the index is not in range. */ public void removeTabAt(int index) { checkIndex(index, 0, tabs.size()); Component c = getComponentAt(index); - super.remove(c); + super.remove(index); c.show(); tabs.remove(index); } /** - * This method removes the component from the JTabbedPane. After - * the component has been removed from the JTabbedPane, it's - * set visible to ensure that it can be seen. + * This method removes the component from the JTabbedPane. After the + * component has been removed from the JTabbedPane, it's set visible to + * ensure that it can be seen. * * @param component The Component to remove. */ @@ -1071,8 +1072,8 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method removes the tab and component from the JTabbedPane. - * It simply calls removeTabAt(int index). + * This method removes the tab and component from the JTabbedPane. It simply + * calls removeTabAt(int index). * * @param index The index of the tab to remove. */ @@ -1082,8 +1083,8 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method removes all tabs and associated components - * from the JTabbedPane. + * This method removes all tabs and associated components from the + * JTabbedPane. */ public void removeAll() { @@ -1102,8 +1103,7 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method returns the number of runs used - * to paint the JTabbedPane. + * This method returns the number of runs used to paint the JTabbedPane. * * @return The number of runs. */ @@ -1204,8 +1204,8 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method returns whether this tab is enabled. - * Disabled tabs cannot be selected. + * This method returns whether this tab is enabled. Disabled tabs cannot be + * selected. * * @param index The index of the tab. * @@ -1244,8 +1244,7 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method returns the bounds of the tab given - * the index. + * This method returns the bounds of the tab given the index. * * @param index The index of the tab. * @@ -1441,9 +1440,9 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method returns a tab index given an (x,y) location. The origin - * of the (x,y) pair will be the JTabbedPane's top left position. The - * tab returned will be the one that contains the point. This method is + * This method returns a tab index given an (x,y) location. The origin of + * the (x,y) pair will be the JTabbedPane's top left position. The tab + * returned will be the one that contains the point. This method is * delegated to the UI. * * @param x The x coordinate of the point. @@ -1470,8 +1469,8 @@ public class JTabbedPane extends JComponent implements Serializable, } /** - * This method returns a string representation of this JTabbedPane. It - * is mainly used for debugging purposes. + * This method returns a string representation of this JTabbedPane. It is + * mainly used for debugging purposes. * * @return A string representation of this JTabbedPane. */ diff --git a/libjava/javax/swing/JTable.java b/libjava/javax/swing/JTable.java index c628b715218..4a81e0400cd 100644 --- a/libjava/javax/swing/JTable.java +++ b/libjava/javax/swing/JTable.java @@ -39,12 +39,14 @@ exception statement from your version. */ package javax.swing; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Rectangle; import java.util.Vector; import java.util.Hashtable; import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ListSelectionEvent; @@ -53,11 +55,14 @@ import javax.swing.event.TableColumnModelEvent; import javax.swing.event.TableColumnModelListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; +import javax.swing.plaf.TableUI; import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; @@ -66,34 +71,259 @@ public class JTable extends JComponent ListSelectionListener, CellEditorListener, Accessible { private static final long serialVersionUID = 3876025080382781659L; - - public static final int AUTO_RESIZE_ALL_COLUMNS = 4; - public static final int AUTO_RESIZE_LAST_COLUMN = 3; - public static final int AUTO_RESIZE_NEXT_COLUMN = 1; + + + /** + * When resizing columns, do not automatically change any columns. In this + * case the table should be enclosed in a {@link JScrollPane} in order to + * accomodate cases in which the table size exceeds its visible area. + */ public static final int AUTO_RESIZE_OFF = 0; + + /** + * When resizing column i, automatically change only the + * single column i+1 to provide or absorb excess space + * requirements. + */ + public static final int AUTO_RESIZE_NEXT_COLUMN = 1; + + /** + * When resizing column i in a table of n + * columns, automatically change all columns in the range [i+1, + * n), uniformly, to provide or absorb excess space requirements. + */ public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2; - protected boolean autoCreateColumnsFromModel; - protected int autoResizeMode; - protected TableCellEditor cellEditor; - protected boolean cellSelectionEnabled; - protected TableColumnModel columnModel; - protected TableModel dataModel; + /** + * When resizing column i in a table of n + * columns, automatically change all columns in the range [0, + * n) (with the exception of column i) uniformly, to provide or + * absorb excess space requirements. + */ + public static final int AUTO_RESIZE_ALL_COLUMNS = 4; + + /** + * When resizing column i in a table of n + * columns, automatically change column n-1 (the last column + * in the table) to provide or absorb excess space requirements. + */ + public static final int AUTO_RESIZE_LAST_COLUMN = 3; + + + /** + * A table mapping {@link java.lang.Class} objects to + * {@link TableCellEditor} objects. This table is consulted by the + * + */ protected Hashtable defaultEditorsByColumnClass; protected Hashtable defaultRenderersByColumnClass; protected int editingColumn; protected int editingRow; - protected Color gridColor; - protected Dimension preferredViewportSize; + + /** + * Whether or not the table should automatically compute a matching + * {@link TableColumnModel} and assign it to the {@link #columnModel} + * property when the {@link #dataModel} property is changed. + * + * @see #setModel() + * @see #createColumnsFromModel() + * @see #setColumnModel() + * @see #setAutoCreateColumnsFromModel() + * @see #getAutoCreateColumnsFromModel() + */ + protected boolean autoCreateColumnsFromModel; + + /** + * A numeric code specifying the resizing behavior of the table. Must be + * one of {@link #AUTO_RESIZE_ALL_COLUMNS} (the default), {@link + * #AUTO_RESIZE_LAST_COLUMN}, {@link #AUTO_RESIZE_NEXT_COLUMN}, {@link + * #AUTO_RESIZE_SUBSEQUENT_COLUMNS}, or {@link #AUTO_RESIZE_OFF}. + * + * @see #doLayout() + * @see #setAutoResizeMode() + * @see #getAutoResizeMode() + */ + protected int autoResizeMode; + + /** + * The height in pixels of any row of the table. All rows in a table are + * of uniform height. This differs from column width, which varies on a + * per-column basis, and is stored in the individual columns of the + * {@link #columnModel}. + * + * @see #getRowHeight() + * @see #setRowHeight() + * @see TableColumn#getWidth() + * @see TableColumn#setWidth() + */ protected int rowHeight; + + /** + * The height in pixels of the gap left between any two rows of the table. + * + * @see #setRowMargin() + * @see #getRowHeight() + * @see #getInterCellSpacing() + * @see #setInterCellSpacing() + * @see TableColumnModel#getColumnMargin() + * @see TableColumnModel#setColumnMargin() + */ protected int rowMargin; + + /** + * Whether or not the table should allow row selection. If the table + * allows both row and column selection, it is said to allow + * "cell selection". Previous versions of the JDK supported cell + * selection as an independent concept, but it is now represented solely + * in terms of simultaneous row and column selection. + * + * @see TableColumnModel#columnSelectionAllowed() + * @see #setRowSelectionAllowed() + * @see #getRowSelectionAllowed() + * @see #getCellSelectionEnabled() + * @see #setCellSelectionEnabled() + */ protected boolean rowSelectionAllowed; - protected Color selectionBackground; - protected Color selectionForeground; + + /** + * @deprecated Use {@link #rowSelectionAllowed}, {@link + * #columnSelectionAllowed}, or the combined methods {@link + * getCellSelectionEnabled} and {@link setCellSelectionEnabled}. + */ + protected boolean cellSelectionEnabled; + + /** + * The model for data stored in the table. Confusingly, the published API + * requires that this field be called dataModel, despite its + * property name. The table listens to its model as a {@link + * TableModelListener}. + * + * @see #tableChanged() + * @see TableModel#addTableModelListener() + */ + protected TableModel dataModel; + + /** + *

    A model of various aspects of the columns of the table, not + * including the data stored in them. The {@link TableColumnModel} + * is principally concerned with holding a set of {@link TableColumn} + * objects, each of which describes the display parameters of a column + * and the numeric index of the column from the data model which the + * column is presenting.

    + * + *

    The TableColumnModel also contains a {@link ListSelectionModel} which + * indicates which columns are currently selected. This selection model + * works in combination with the {@link selectionModel} of the table + * itself to specify a table selection: a combination of row and + * column selections.

    + * + *

    Most application programmers do not need to work with this property + * at all: setting {@link #autoCreateColumnsFromModel} will construct the + * columnModel automatically, and the table acts as a facade for most of + * the interesting properties of the columnModel anyways.

    + * + * @see #setColumnModel() + * @see #getColumnModel() + */ + protected TableColumnModel columnModel; + + /** + * A model of the rows of this table which are currently selected. This + * model is used in combination with the column selection model held as a + * member of the {@link columnModel} property, to represent the rows and + * columns (or both: cells) of the table which are currently selected. + * + * @see #rowSelectionAllowed + * @see #setSelectionModel() + * @see #getSelectionModel() + * @see TableColumnModel#getSelectionModel() + * @see ListSelectionModel#addListSelectionListener() + */ protected ListSelectionModel selectionModel; + + /** + * The accessibleContext property. + */ + protected AccessibleContext accessibleContext; + + /** + * The current cell editor. + */ + protected TableCellEditor cellEditor; + + /** + * Whether or not drag-and-drop is enabled on this table. + * + * @see #setDragEnabled() + * @see #getDragEnabled() + */ + protected boolean dragEnabled; + + /** + * The color to paint the grid lines of the table, when either {@link + * #showHorizontalLines} or {@link #showVerticalLines} is set. + * + * @see #setGridColor() + * @see #getGridColor() + */ + protected Color gridColor; + + /** + * The size this table would prefer its viewport assume, if it is + * contained in a {@link JScrollPane}. + * + * @see #setPreferredScrollableViewportSize() + * @see #getPreferredScrollableViewportSize() + */ + protected Dimension preferredScrollableViewportSize; + + /** + * The color to paint the background of selected cells. Fires a property + * change event with name {@link #SELECTION_BACKGROUND_CHANGED_PROPERTY} + * when its value changes. + * + * @see #setSelectionBackground() + * @see #getSelectionBackground() + */ + Color selectionBackground; + + /** + * The name carried in property change events when the {@link + * #selectionBackground} property changes. + */ + private static final String SELECTION_BACKGROUND_CHANGED_PROPERTY = "selectionBackground"; + + /** + * The color to paint the foreground of selected cells. Fires a property + * change event with name {@link #SELECTION_FOREGROUND_CHANGED_PROPERTY} + * when its value changes. + * + * @see #setSelectionForeground() + * @see #getSelectionForeground() + */ + Color selectionForeground; + + /** + * The name carried in property change events when the + * {@link #selectionForeground} property changes. + */ + private static final String SELECTION_FOREGROUND_CHANGED_PROPERTY = "selectionForeground"; + + /** + * The showHorizontalLines property. + */ protected boolean showHorizontalLines; + + /** + * The showVerticalLines property. + */ protected boolean showVerticalLines; + + /** + * The tableHeader property. + */ protected JTableHeader tableHeader; + /** * Creates a new JTable instance. @@ -156,8 +386,33 @@ public class JTable extends JComponent public JTable (TableModel dm, TableColumnModel cm, ListSelectionModel sm) { this.dataModel = dm == null ? createDefaultDataModel() : dm; - this.columnModel = cm == null ? createDefaultColumnModel() : cm; - this.selectionModel = sm == null ? createDefaultListSelectionModel() : sm; + setSelectionModel(sm == null ? createDefaultListSelectionModel() : sm); + + this.columnModel = cm; + this.autoCreateColumnsFromModel = false; + if (cm == null) + { + this.autoCreateColumnsFromModel = true; + createColumnsFromModel(); + } + this.columnModel.addColumnModelListener(this); + + this.defaultRenderersByColumnClass = new Hashtable(); + this.defaultEditorsByColumnClass = new Hashtable(); + + this.autoResizeMode = AUTO_RESIZE_ALL_COLUMNS; + this.rowHeight = 16; + this.rowMargin = 1; + this.rowSelectionAllowed = true; + // this.accessibleContext = new AccessibleJTable(); + this.cellEditor = null; + this.dragEnabled = false; + this.preferredScrollableViewportSize = new Dimension(450,400); + this.showHorizontalLines = true; + this.showVerticalLines = true; + setInterCellSpacing(new Dimension(1,1)); + setTableHeader(new JTableHeader(columnModel)); + updateUI(); } /** @@ -178,216 +433,1129 @@ public class JTable extends JComponent { return new JScrollPane(table); } - - public void clearSelection() + + protected TableColumnModel createDefaultColumnModel() { - selectionModel.clearSelection(); + return new DefaultTableColumnModel(); } - public void columnAdded (TableColumnModelEvent event) + protected TableModel createDefaultDataModel() { - throw new Error ("Not implemented"); + return new DefaultTableModel(); } - public void columnMarginChanged (ChangeEvent event) + protected ListSelectionModel createDefaultListSelectionModel() { - throw new Error ("Not implemented"); + return new DefaultListSelectionModel(); } - - public void columnMoved (TableColumnModelEvent event) + + private void createColumnsFromModel() { - throw new Error ("Not implemented"); + if (dataModel == null) + return; + + TableColumnModel cm = createDefaultColumnModel(); + + for (int i = 0; i < dataModel.getColumnCount(); ++i) + { + cm.addColumn(new TableColumn(i)); + } + this.setColumnModel(cm); } - - public void columnRemoved (TableColumnModelEvent event) + + // listener support + + public void columnAdded (TableColumnModelEvent event) { - throw new Error ("Not implemented"); + revalidate(); + repaint(); } - - public void columnSelectionChanged (ListSelectionEvent event) + + public void columnMarginChanged (ChangeEvent event) { - throw new Error ("Not implemented"); + revalidate(); + repaint(); } - - protected TableColumnModel createDefaultColumnModel() + + public void columnMoved (TableColumnModelEvent event) { - return new DefaultTableColumnModel(); + revalidate(); + repaint(); } - protected TableModel createDefaultDataModel() + public void columnRemoved (TableColumnModelEvent event) { - return new DefaultTableModel(); + revalidate(); + repaint(); } - - protected ListSelectionModel createDefaultListSelectionModel() + + public void columnSelectionChanged (ListSelectionEvent event) { - return new DefaultListSelectionModel(); + repaint(); } public void editingCanceled (ChangeEvent event) { - throw new Error ("Not implemented"); + repaint(); } public void editingStopped (ChangeEvent event) { - throw new Error ("Not implemented"); + repaint(); } - public TableColumnModel getColumnModel () - { - return columnModel; - } - - public TableModel getModel() - { - return dataModel; - } - - public Dimension getPreferredScrollableViewportSize () + public void tableChanged (TableModelEvent event) { - throw new Error ("Not implemented"); + repaint(); } - public int getScrollableBlockIncrement (Rectangle visibleRect, int orientation, int direction) + public void valueChanged (ListSelectionEvent event) { - throw new Error ("Not implemented"); + repaint(); } - public boolean getScrollableTracksViewportHeight () - { - throw new Error ("Not implemented"); - } - - public boolean getScrollableTracksViewportWidth () + + /** + * Calculate the visible rectangle for a particular row and column. The + * row and column are specified in visual terms; the column may not match + * the {@link #dataModel} column. + * + * @param row the visible row to get the cell rectangle of + * + * @param column the visible column to get the cell rectangle of, which may + * differ from the {@link #dataModel} column + * + * @param includeSpacing whether or not to include the cell margins in the + * resulting cell. If false, the result will only contain the + * inner area of the target cell, not including its margins. + * + * @return a rectangle enclosing the specified cell + */ + public Rectangle getCellRect(int row, + int column, + boolean includeSpacing) { - throw new Error ("Not implemented"); + int height = getHeight(); + int width = columnModel.getColumn(column).getWidth(); + int x_gap = columnModel.getColumnMargin(); + int y_gap = rowMargin; + + column = Math.max(0, Math.min(column, getColumnCount() - 1)); + row = Math.max(0, Math.min(row, getRowCount() - 1)); + + int x = 0; + int y = (height + y_gap) * row; + + for (int i = 0; i < column; ++i) + { + x += columnModel.getColumn(i).getWidth(); + x += x_gap; + } + + if (includeSpacing) + return new Rectangle(x, y, width, height); + else + return new Rectangle(x, y, width - x_gap, height - y_gap); } - public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation, int direction) + public void clearSelection() { - throw new Error ("Not implemented"); + selectionModel.clearSelection(); } + /** + * Get the value of the {@link #selectedRow} property by delegation to + * the {@link ListSelectionModel#getMinSelectionIndex} method of the + * {@link #selectionModel} field. + * + * @return The current value of the selectedRow property + */ public int getSelectedRow () { return selectionModel.getMinSelectionIndex(); } - public ListSelectionModel getSelectionModel () + /** + * Get the value of the {@link #selectionModel} property. + * + * @return The current value of the property + */ + public ListSelectionModel getSelectionModel() { if (! rowSelectionAllowed) return null; return selectionModel; } - - public void tableChanged (TableModelEvent event) + + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { - throw new Error ("Not implemented"); + if (orientation == SwingConstants.VERTICAL) + return visibleRect.height * direction; + else + return visibleRect.width * direction; } - public void setModel (TableModel model) - { - if (model == null) - throw new IllegalArgumentException(); + /** + * Get the value of the {@link #scrollableTracksViewportHeight} property. + * + * @return The constant value false + */ - // FIXME: Should we deregister from old model ? - - dataModel = model; - dataModel.addTableModelListener(this); + public boolean getScrollableTracksViewportHeight() + { + return false; } + + /** + * Get the value of the {@link #scrollableTracksViewportWidth} property. + * + * @return true unless the {@link autoResizeMode} prperty is + * AUTO_RESIZE_OFF + */ - public void setSelectionMode (int selectionMode) + public boolean getScrollableTracksViewportWidth() { - throw new Error ("Not implemented"); + if (autoResizeMode == AUTO_RESIZE_OFF) + return false; + else + return true; } - public void setSelectionModel (ListSelectionModel model) + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { - if (model == null) - throw new IllegalArgumentException(); + // FIXME: I don't exactly know what sun does here. in both cases they + // pick values which do *not* simply expose the next cell in a given + // scroll direction. - // FIXME: Should we deregister from old model ? - - selectionModel = model; - selectionModel.addListSelectionListener(this); + if (orientation == SwingConstants.VERTICAL) + return rowHeight; + else + { + int sum = 0; + for (int i = 0; i < getColumnCount(); ++i) + sum += columnModel.getColumn(0).getWidth(); + return getColumnCount() == 0 ? 10 : sum / getColumnCount(); + } } - public void setShowGrid (boolean showGrid) + + public TableCellEditor getCellEditor(int row, int column) { - throw new Error ("Not implemented"); + TableCellEditor editor = columnModel.getColumn(column).getCellEditor(); + + if (editor == null) + editor = getDefaultEditor(dataModel.getColumnClass(column)); + + return editor; } - public void valueChanged (ListSelectionEvent event) + public TableCellEditor getDefaultEditor(Class columnClass) { - throw new Error ("Not implemented"); + if (defaultEditorsByColumnClass.containsKey(columnClass)) + return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass); + else + { + TableCellEditor r = new DefaultCellEditor(new JTextField()); + defaultEditorsByColumnClass.put(columnClass, r); + return r; + } } - public JTableHeader getTableHeader() + + + public TableCellRenderer getCellRenderer(int row, int column) { - return tableHeader; + TableCellRenderer renderer = + columnModel.getColumn(column).getCellRenderer(); + + if (renderer == null) + renderer = getDefaultRenderer(dataModel.getColumnClass(column)); + + return renderer; } - public void setTableHeader(JTableHeader newHeader) + public TableCellRenderer getDefaultRenderer(Class columnClass) { - tableHeader = newHeader; + if (defaultRenderersByColumnClass.containsKey(columnClass)) + return (TableCellRenderer) defaultRenderersByColumnClass.get(columnClass); + else + { + TableCellRenderer r = new DefaultTableCellRenderer(); + defaultRenderersByColumnClass.put(columnClass, r); + return r; + } } - public boolean getColumnSelectionAllowed() + public int convertColumnIndexToModel(int vc) { - return columnModel.getColumnSelectionAllowed(); + if (vc < 0) + return vc; + else if (vc > getColumnCount()) + return -1; + else + return columnModel.getColumn(vc).getModelIndex(); } - - public void setColumnSelectionAllowed(boolean flag) + + public int convertColumnIndexToView(int mc) { - columnModel.setColumnSelectionAllowed(flag); + if (mc < 0) + return mc; + int ncols = getColumnCount(); + for (int vc = 0; vc < ncols; ++vc) + { + if (columnModel.getColumn(vc).getModelIndex() == mc) + return vc; + } + return -1; } - public boolean getRowSelectionAllowed() + public Component prepareRenderer(TableCellRenderer renderer, + int row, + int column) { - return rowSelectionAllowed; + boolean rsa = getRowSelectionAllowed(); + boolean csa = getColumnSelectionAllowed(); + boolean rs = rsa ? getSelectionModel().isSelectedIndex(row) : false; + boolean cs = csa ? columnModel.getSelectionModel().isSelectedIndex(column) : false; + boolean isSelected = ((rsa && csa && rs && cs) + || (rsa && !csa && rs) + || (!rsa && csa && cs)); + + return renderer.getTableCellRendererComponent(this, + dataModel.getValueAt(row, + convertColumnIndexToView(column)), + isSelected, + false, // hasFocus + row, column); } - - public void setRowSelectionAllowed(boolean flag) + + + /** + * Get the value of the {@link #autoCreateColumnsFromModel} property. + * + * @return The current value of the property + */ + public boolean getAutoCreateColumnsFromModel() { - rowSelectionAllowed = flag; + return autoCreateColumnsFromModel; } + /** + * Get the value of the {@link #autoResizeMode} property. + * + * @return The current value of the property + */ public int getAutoResizeMode() { return autoResizeMode; } - public void setAutoResizeMode(int mode) + /** + * Get the value of the {@link #rowHeight} property. + * + * @return The current value of the property + */ + public int getRowHeight() { - autoResizeMode = mode; + return rowHeight; } - public int getColumnCount() + /** + * Get the value of the {@link #rowMargin} property. + * + * @return The current value of the property + */ + public int getRowMargin() { - return dataModel.getColumnCount(); + return rowMargin; } - public int getRowCount() + /** + * Get the value of the {@link #rowSelectionAllowed} property. + * + * @return The current value of the property + */ + public boolean getRowSelectionAllowed() { - return dataModel.getRowCount(); + return rowSelectionAllowed; } - public TableCellRenderer getCellRenderer(int row, int column) + /** + * Get the value of the {@link #cellSelectionEnabled} property. + * + * @return The current value of the property + */ + public boolean getCellSelectionEnabled() { - TableCellRenderer renderer = - columnModel.getColumn(column).getCellRenderer(); - - if (renderer == null) - renderer = getDefaultRenderer(dataModel.getColumnClass(column)); - - return renderer; + return getColumnSelectionAllowed() && getRowSelectionAllowed(); } - public TableCellRenderer getDefaultRenderer(Class columnClass) + /** + * Get the value of the {@link #dataModel} property. + * + * @return The current value of the property + */ + public TableModel getModel() + { + return dataModel; + } + + /** + * Get the value of the {@link #columnCount} property by + * delegation to the @{link #dataModel} field. + * + * @return The current value of the columnCount property + */ + public int getColumnCount() + { + return dataModel.getColumnCount(); + } + + /** + * Get the value of the {@link #rowCount} property by + * delegation to the @{link #dataModel} field. + * + * @return The current value of the rowCount property + */ + public int getRowCount() + { + return dataModel.getRowCount(); + } + + /** + * Get the value of the {@link #columnModel} property. + * + * @return The current value of the property + */ + public TableColumnModel getColumnModel() + { + return columnModel; + } + + /** + * Get the value of the {@link #selectedColumn} property by + * delegation to the @{link #columnModel} field. + * + * @return The current value of the selectedColumn property + */ + public int getSelectedColumn() + { + return columnModel.getSelectionModel().getMinSelectionIndex(); + } + + private static int countSelections(ListSelectionModel lsm) + { + int lo = lsm.getMinSelectionIndex(); + int hi = lsm.getMaxSelectionIndex(); + int sum = 0; + if (lo != -1 && hi != -1) + { + switch (lsm.getSelectionMode()) + { + case ListSelectionModel.SINGLE_SELECTION: + sum = 1; + break; + + case ListSelectionModel.SINGLE_INTERVAL_SELECTION: + sum = hi - lo; + break; + + case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: + for (int i = lo; i < hi; ++i) + if (lsm.isSelectedIndex(i)) + ++sum; + break; + } + } + return sum; + } + + private static int[] getSelections(ListSelectionModel lsm) + { + int sz = countSelections(lsm); + int [] ret = new int[sz]; + + int lo = lsm.getMinSelectionIndex(); + int hi = lsm.getMaxSelectionIndex(); + int j = 0; + java.util.ArrayList ls = new java.util.ArrayList(); + if (lo != -1 && hi != -1) + { + switch (lsm.getSelectionMode()) + { + case ListSelectionModel.SINGLE_SELECTION: + ret[0] = lo; + break; + + case ListSelectionModel.SINGLE_INTERVAL_SELECTION: + for (int i = lo; i < hi; ++i) + ret[j++] = i; + break; + + case ListSelectionModel.MULTIPLE_INTERVAL_SELECTION: + for (int i = lo; i < hi; ++i) + if (lsm.isSelectedIndex(i)) + ret[j++] = i; + break; + } + } + return ret; + } + + /** + * Get the value of the {@link #selectedColumnCount} property by + * delegation to the @{link #columnModel} field. + * + * @return The current value of the selectedColumnCount property + */ + public int getSelectedColumnCount() + { + return countSelections(columnModel.getSelectionModel()); + } + + /** + * Get the value of the {@link #selectedColumns} property by + * delegation to the @{link #columnModel} field. + * + * @return The current value of the selectedColumns property + */ + public int[] getSelectedColumns() + { + return getSelections(columnModel.getSelectionModel()); + } + + /** + * Get the value of the {@link #columnSelectionAllowed} property. + * + * @return The current value of the columnSelectionAllowed property + */ + public boolean getColumnSelectionAllowed() + { + return getColumnModel().getColumnSelectionAllowed(); + } + + /** + * Get the value of the {@link #selectedRowCount} property by + * delegation to the @{link #selectionModel} field. + * + * @return The current value of the selectedRowCount property + */ + public int getSelectedRowCount() + { + return countSelections(selectionModel); + } + + /** + * Get the value of the {@link #selectedRows} property by + * delegation to the @{link #selectionModel} field. + * + * @return The current value of the selectedRows property + */ + public int[] getSelectedRows() + { + return getSelections(selectionModel); + } + + /** + * Get the value of the {@link #accessibleContext} property. + * + * @return The current value of the property + */ + public AccessibleContext getAccessibleContext() + { + return accessibleContext; + } + + /** + * Get the value of the {@link #cellEditor} property. + * + * @return The current value of the property + */ + public TableCellEditor getCellEditor() + { + return cellEditor; + } + + /** + * Get the value of the {@link #dragEnabled} property. + * + * @return The current value of the property + */ + public boolean getDragEnabled() + { + return dragEnabled; + } + + /** + * Get the value of the {@link #gridColor} property. + * + * @return The current value of the property + */ + public Color getGridColor() + { + return gridColor; + } + + /** + * Get the value of the {@link #interCellSpacing} property. + * + * @return The current value of the property + */ + public Dimension getInterCellSpacing() + { + return new Dimension(columnModel.getColumnMargin(), rowMargin); + } + + /** + * Get the value of the {@link #preferredScrollableViewportSize} property. + * + * @return The current value of the property + */ + public Dimension getPreferredScrollableViewportSize() + { + return preferredScrollableViewportSize; + } + + /** + * Get the value of the {@link #selectionBackground} property. + * + * @return The current value of the property + */ + public Color getSelectionBackground() + { + return selectionBackground; + } + + /** + * Get the value of the {@link #selectionForeground} property. + * + * @return The current value of the property + */ + public Color getSelectionForeground() + { + return selectionForeground; + } + + /** + * Get the value of the {@link #showHorizontalLines} property. + * + * @return The current value of the property + */ + public boolean getShowHorizontalLines() + { + return showHorizontalLines; + } + + /** + * Get the value of the {@link #showVerticalLines} property. + * + * @return The current value of the property + */ + public boolean getShowVerticalLines() + { + return showVerticalLines; + } + + /** + * Get the value of the {@link #tableHeader} property. + * + * @return The current value of the property + */ + public JTableHeader getTableHeader() + { + return tableHeader; + } + + /** + * Set the value of the {@link #autoCreateColumnsFromModel} property. + * + * @param a The new value of the autoCreateColumnsFromModel property + */ + public void setAutoCreateColumnsFromModel(boolean a) + { + autoCreateColumnsFromModel = a; + } + + /** + * Set the value of the {@link #autoResizeMode} property. + * + * @param a The new value of the autoResizeMode property + */ + public void setAutoResizeMode(int a) { - // FIXME: - return null; + autoResizeMode = a; + revalidate(); + repaint(); } + + /** + * Set the value of the {@link #rowHeight} property. + * + * @param r The new value of the rowHeight property + */ + public void setRowHeight(int r) + { + rowHeight = r; + revalidate(); + repaint(); + } + + /** + * Set the value of the {@link #rowMargin} property. + * + * @param r The new value of the rowMargin property + */ + public void setRowMargin(int r) + { + rowMargin = r; + revalidate(); + repaint(); + } + + /** + * Set the value of the {@link #rowSelectionAllowed} property. + * + * @param r The new value of the rowSelectionAllowed property + */ + public void setRowSelectionAllowed(boolean r) + { + rowSelectionAllowed = r; + repaint(); + } + + /** + * Set the value of the {@link #cellSelectionEnabled} property. + * + * @param c The new value of the cellSelectionEnabled property + */ + public void setCellSelectionEnabled(boolean c) + { + setColumnSelectionAllowed(c); + setRowSelectionAllowed(c); + // for backward-compatibility sake: + cellSelectionEnabled = true; + } + + /** + *

    Set the value of the {@link #dataModel} property.

    + * + *

    Unregister this as a {@link TableModelListener} from + * previous {@link #dataModel} and register it with new parameter + * m.

    + * + * @param m The new value of the model property + */ + public void setModel(TableModel m) + { + if (m == null) + throw new IllegalArgumentException(); + TableModel tmp = dataModel; + if (autoCreateColumnsFromModel) + createColumnsFromModel(); + if (tmp != null) + tmp.removeTableModelListener(this); + if (m != null) + m.addTableModelListener(this); + dataModel = m; + revalidate(); + repaint(); + } + + /** + *

    Set the value of the {@link #columnModel} property.

    + * + *

    Unregister this as a {@link TableColumnModelListener} + * from previous {@link #columnModel} and register it with new parameter + * c.

    + * + * @param c The new value of the columnModel property + */ + public void setColumnModel(TableColumnModel c) + { + if (c == null) + throw new IllegalArgumentException(); + TableColumnModel tmp = columnModel; + if (tmp != null) + tmp.removeColumnModelListener(this); + if (c != null) + c.addColumnModelListener(this); + columnModel = c; + if (dataModel != null && columnModel != null) + { + int ncols = getColumnCount(); + for (int i = 0; i < ncols; ++i) + columnModel.getColumn(i).setHeaderValue(dataModel.getColumnName(i)); + } + revalidate(); + repaint(); + } + + /** + * Set the value of the {@link #columnSelectionAllowed} property. + * + * @param c The new value of the property + */ + public void setColumnSelectionAllowed(boolean c) + { + getColumnModel().setColumnSelectionAllowed(c); + repaint(); + } + + /** + *

    Set the value of the {@link #selectionModel} property.

    + * + *

    Unregister this as a {@link ListSelectionListener} + * from previous {@link #selectionModel} and register it with new + * parameter s.

    + * + * @param s The new value of the selectionModel property + */ + public void setSelectionModel(ListSelectionModel s) + { + if (s == null) + throw new IllegalArgumentException(); + ListSelectionModel tmp = selectionModel; + if (tmp != null) + tmp.removeListSelectionListener(this); + if (s != null) + s.addListSelectionListener(this); + selectionModel = s; + } + + /** + * Set the value of the {@link #selectionMode} property by + * delegation to the {@link #selectionModel} field. + * + * @param s The new value of the property + */ + public void setSelectionMode(int s) + { + selectionModel.setSelectionMode(s); + repaint(); + } + + /** + *

    Set the value of the {@link #cellEditor} property.

    + * + *

    Unregister this as a {@link CellEditorListener} from + * previous {@link #cellEditor} and register it with new parameter + * c.

    + * + * @param c The new value of the cellEditor property + */ + public void setCellEditor(TableCellEditor c) + { + TableCellEditor tmp = cellEditor; + if (tmp != null) + tmp.removeCellEditorListener(this); + if (c != null) + c.addCellEditorListener(this); + cellEditor = c; + } + + /** + * Set the value of the {@link #dragEnabled} property. + * + * @param d The new value of the dragEnabled property + */ + public void setDragEnabled(boolean d) + { + dragEnabled = d; + } + + /** + * Set the value of the {@link #gridColor} property. + * + * @param g The new value of the gridColor property + */ + public void setGridColor(Color g) + { + gridColor = g; + repaint(); + } + + /** + * Set the value of the {@link #interCellSpacing} property. + * + * @param i The new value of the interCellSpacing property + */ + public void setInterCellSpacing(Dimension i) + { + rowMargin = i.height; + columnModel.setColumnMargin(i.width); + repaint(); + } + + /** + * Set the value of the {@link #preferredScrollableViewportSize} property. + * + * @param p The new value of the preferredScrollableViewportSize property + */ + public void setPreferredScrollableViewportSize(Dimension p) + { + preferredScrollableViewportSize = p; + revalidate(); + repaint(); + } + + /** + *

    Set the value of the {@link #selectionBackground} property.

    + * + *

    Fire a PropertyChangeEvent with name {@link + * #SELECTION_BACKGROUND_CHANGED_PROPERTY} to registered listeners, if + * selectionBackground changed.

    + * + * @param s The new value of the selectionBackground property + */ + public void setSelectionBackground(Color s) + { + Color tmp = selectionBackground; + selectionBackground = s; + if (((tmp == null && s != null) + || (s == null && tmp != null) + || (tmp != null && s != null && !tmp.equals(s)))) + firePropertyChange(SELECTION_BACKGROUND_CHANGED_PROPERTY, tmp, s); + repaint(); + } + + /** + *

    Set the value of the {@link #selectionForeground} property.

    + * + *

    Fire a PropertyChangeEvent with name {@link + * SELECTION_FOREGROUND_CHANGED_PROPERTY} to registered listeners, if + * selectionForeground changed.

    + * + * @param s The new value of the selectionForeground property + */ + public void setSelectionForeground(Color s) + { + Color tmp = selectionForeground; + selectionForeground = s; + if (((tmp == null && s != null) + || (s == null && tmp != null) + || (tmp != null && s != null && !tmp.equals(s)))) + firePropertyChange(SELECTION_FOREGROUND_CHANGED_PROPERTY, tmp, s); + repaint(); + } + + /** + * Set the value of the {@link #showGrid} property. + * + * @param s The new value of the showGrid property + */ + public void setShowGrid(boolean s) + { + setShowVerticalLines(s); + setShowHorizontalLines(s); + } + + /** + * Set the value of the {@link #showHorizontalLines} property. + * + * @param s The new value of the showHorizontalLines property + */ + public void setShowHorizontalLines(boolean s) + { + showHorizontalLines = s; + repaint(); + } + + /** + * Set the value of the {@link #showVerticalLines} property. + * + * @param s The new value of the showVerticalLines property + */ + public void setShowVerticalLines(boolean s) + { + showVerticalLines = s; + repaint(); + } + + /** + * Set the value of the {@link #tableHeader} property. + * + * @param t The new value of the tableHeader property + */ + public void setTableHeader(JTableHeader t) + { + if (tableHeader != null) + tableHeader.setTable(null); + tableHeader = t; + if (tableHeader != null) + tableHeader.setTable(this); + revalidate(); + repaint(); + } + + protected void configureEnclosingScrollPane() + { + JScrollPane jsp = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this); + if (jsp != null && tableHeader != null) + { + jsp.setColumnHeaderView(tableHeader); + } + } + + protected void unconfigureEnclosingScrollPane() + { + JScrollPane jsp = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, this); + if (jsp != null) + { + jsp.setColumnHeaderView(null); + } + } + + + public void addNotify() + { + super.addNotify(); + configureEnclosingScrollPane(); + } + + public void removeNotify() + { + super.addNotify(); + unconfigureEnclosingScrollPane(); + } + + + /** + * Sun javadocs describe an unusual implementation of + * doLayout which involves some private interfaces. We try + * to implement the same algorithm as is documented, but using the + * columnModel directly. We still use a private helper method, but it has + * a simpler signature. + */ + + private void distributeSpill(TableColumn[] cols, int spill) + { + int MIN = 0; + int MAX = 0; + int PREF = 0; + + int[] min = new int[cols.length]; + int[] max = new int[cols.length]; + int[] pref = new int[cols.length]; + + for (int i = 0; i < cols.length; ++i) + { + pref[i] = cols[i].getPreferredWidth(); + min[i] = cols[i].getMinWidth(); + max[i] = cols[i].getMaxWidth(); + PREF += pref[i]; + MIN += min[i]; + MAX += max[i]; + } + + for (int i = 0; i < cols.length; ++i) + { + int adj = 0; + if (spill > 0) + adj = (spill * (pref[i] - min[i])) / (PREF - MIN); + else + adj = (spill * (max[i] - pref[i])) / (MAX - PREF); + cols[i].setWidth(pref[i] + adj); + } + } + + public void doLayout() + { + TableColumn resizingColumn = null; + + int ncols = getColumnCount(); + if (ncols < 1) + return; + + int[] pref = new int[ncols]; + int prefSum = 0; + int rCol = -1; + + if (tableHeader != null) + resizingColumn = tableHeader.getResizingColumn(); + + for (int i = 0; i < ncols; ++i) + { + TableColumn col = columnModel.getColumn(i); + int p = col.getWidth(); + pref[i] = p; + prefSum += p; + if (resizingColumn == col) + rCol = i; + } + + int spill = prefSum - getWidth(); + + if (resizingColumn != null) + { + TableColumn col; + TableColumn [] cols; + + switch (getAutoResizeMode()) + { + case AUTO_RESIZE_LAST_COLUMN: + col = columnModel.getColumn(ncols-1); + col.setWidth(col.getPreferredWidth() + spill); + break; + + case AUTO_RESIZE_NEXT_COLUMN: + col = columnModel.getColumn(ncols-1); + col.setWidth(col.getPreferredWidth() + spill); + break; + + case AUTO_RESIZE_ALL_COLUMNS: + cols = new TableColumn[ncols]; + for (int i = 0; i < ncols; ++i) + cols[i] = columnModel.getColumn(i); + distributeSpill(cols, spill); + break; + + case AUTO_RESIZE_SUBSEQUENT_COLUMNS: + cols = new TableColumn[ncols]; + for (int i = rCol; i < ncols; ++i) + cols[i] = columnModel.getColumn(i); + distributeSpill(cols, spill); + break; + + case AUTO_RESIZE_OFF: + default: + } + } + else + { + TableColumn [] cols = new TableColumn[ncols]; + for (int i = 0; i < ncols; ++i) + cols[i] = columnModel.getColumn(i); + distributeSpill(cols, spill); + } + } + + public void sizeColumnsToFit(boolean lastColumnOnly) + { + doLayout(); + } + + public void sizeColumnsToFit(int resizingColumn) + { + doLayout(); + } + + + public String getUIClassID() + { + return "TableUI"; + } + + public TableUI getUI() + { + return (TableUI) ui; + } + + public void updateUI() + { + setUI((TableUI) UIManager.getUI(this)); + revalidate(); + repaint(); + } + } diff --git a/libjava/javax/swing/JTextField.java b/libjava/javax/swing/JTextField.java index 8872af6906d..4466f5ad5b3 100644 --- a/libjava/javax/swing/JTextField.java +++ b/libjava/javax/swing/JTextField.java @@ -137,9 +137,15 @@ public class JTextField extends JTextComponent */ public JTextField(Document doc, String text, int columns) { + if (columns < 0) + throw new IllegalArgumentException(); + + this.columns = columns; + setDocument(doc == null ? createDefaultModel() : doc); - setText(text); - setColumns(columns); + + if (text != null) + setText(text); } /** diff --git a/libjava/javax/swing/JToolTip.java b/libjava/javax/swing/JToolTip.java index 87e4610db40..daf9f0a21e5 100644 --- a/libjava/javax/swing/JToolTip.java +++ b/libjava/javax/swing/JToolTip.java @@ -1,4 +1,4 @@ -/* JToolTip.java -- +/* JToolTip.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,25 +35,160 @@ 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 javax.swing; +import java.awt.AWTEvent; import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; +import javax.swing.plaf.ToolTipUI; + +/** + * This class is used to display ToolTips. ToolTips are small floating windows + * that display text when the mouse comes to rest over a Component. ToolTips + * are set for JComponents using JComponent.setToolTipText(String). + */ public class JToolTip extends JComponent implements Accessible { + /** DOCUMENT ME! */ private static final long serialVersionUID = -1138929898906751643L; - + + /** + * DOCUMENT ME! + */ + protected class AccessibleJToolTip extends AccessibleJComponent + { + /** + * Creates a new AccessibleJToolTip object. + */ + protected AccessibleJToolTip() + { + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getAccessibleDescription() + { + return null; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public AccessibleRole getAccessibleRole() + { + return null; + } + } + + /** The text to display in the JToolTip. */ String text; + /** The JComponent this JToolTip is used for. */ + JComponent component; + + /** + * Creates a new JToolTip object. + */ public JToolTip() { + disableEvents(AWTEvent.MOUSE_EVENT_MASK); + updateUI(); } - public void setTipText(String newText) + /** + * This method returns the text this JToolTip displays. + * + * @return The text that this JToolTip displays. + */ + public String getTipText() { - this.text = newText; + return text; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public AccessibleContext getAccessibleContext() + { + return null; } -} + /** + * This method returns the JComponent this JToolTip displays for. + * + * @return The JComponent this JToolTip displays for. + */ + public JComponent getComponent() + { + return component; + } + /** + * This method returns the UI responsible for displaying this JToolTip. + * + * @return The UI responsible for displaying this JToolTip. + */ + public ToolTipUI getUI() + { + return (ToolTipUI) ui; + } + + /** + * This method returns the String identifier for the UI class. + * + * @return The String identifier for the UI class. + */ + public String getUIClassID() + { + return "ToolTipUI"; + } + + /** + * This method returns a debugging String describing the JToolTip. + * + * @return A debugging String describing the JToolTip. + */ + protected String paramString() + { + return "JToolTip"; + } + + /** + * This method sets the JComponent that the JToolTip displays for. + * + * @param c The JComponent that the JToolTip displays for. + */ + public void setComponent(JComponent c) + { + component = c; + } + + /** + * This method sets the text that the JToolTip displays. + * + * @param tipText The text that the JToolTip displays. + */ + public void setTipText(String tipText) + { + text = tipText; + } + + /** + * This method resets the UI used to the Look and Feel default. + */ + public void updateUI() + { + setUI((ToolTipUI) UIManager.getUI(this)); + revalidate(); + repaint(); + } +} diff --git a/libjava/javax/swing/JViewport.java b/libjava/javax/swing/JViewport.java index 47ccdf7097f..a36118371ce 100644 --- a/libjava/javax/swing/JViewport.java +++ b/libjava/javax/swing/JViewport.java @@ -249,8 +249,13 @@ public class JViewport extends JComponent public void setView(Component v) { - add(v); - fireStateChanged(); + while (getComponentCount() > 0) + remove(0); + if (v != null) + { + add(v); + fireStateChanged(); + } } public void revalidate() diff --git a/libjava/javax/swing/KeyStroke.java b/libjava/javax/swing/KeyStroke.java index b78be0c7392..afdbae8300a 100644 --- a/libjava/javax/swing/KeyStroke.java +++ b/libjava/javax/swing/KeyStroke.java @@ -37,235 +37,69 @@ exception statement from your version. */ package javax.swing; +import java.awt.AWTKeyStroke; import java.awt.event.KeyEvent; import java.io.Serializable; -/** - * KeyStroke - * @author Andrew Selkirk - * @version 1.0 - */ -public class KeyStroke implements Serializable +public class KeyStroke + extends AWTKeyStroke + implements Serializable { static final long serialVersionUID = -9060180771037902530L; - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * keyChar - */ - private char keyChar = 0; - - /** - * keyCode - */ - private int keyCode = 0; - - /** - * modifiers - */ - private int modifiers = 0; - - /** - * onKeyRelease - */ - private boolean onKeyRelease = false; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor KeyStroke - */ - private KeyStroke() { - } // KeyStroke() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * hashCode - * @returns int - */ - public int hashCode() { - return 0; // TODO - } // hashCode() - - /** - * equals - * @param object TODO - * @returns boolean - */ - public boolean equals(Object object) { - - // Variables - KeyStroke key; - - if (object instanceof KeyStroke) { - key = (KeyStroke) object; - if (key.keyChar == keyChar && - key.keyCode == keyCode && - key.modifiers == modifiers && - key.onKeyRelease == onKeyRelease) { - return true; - } // if - } // if - return false; - - } // equals() - - /** - * toString - * @returns String - */ - public String toString() { - return null; // TODO - } // toString() - - /** - * getKeyStroke - * @param keyChar TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStroke(char keyChar) { - - // Variables - KeyStroke key; - - key = new KeyStroke(); - key.keyChar = keyChar; - return key; - - } // getKeyStroke() - - /** - * getKeyStroke - deprecated - * @param keyChar TODO - * @param onKeyRelease TODO - * @returns KeyStroke - * @deprecated Use getKeyStroke(char) - */ - public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) { - KeyStroke key = getKeyStroke(keyChar); - key.onKeyRelease = onKeyRelease; - return key; - } // getKeyStroke() - - /** - * getKeyStroke - * @param keyChar TODO - * @param modifiers TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStroke(Character keyChar, int modifiers) { - KeyStroke key = getKeyStroke(keyChar.charValue()); - key.modifiers = modifiers; - return key; - } // getKeyStroke() - - /** - * getKeyStroke - * @param keyCode TODO - * @param modifiers TODO - * @param onKeyRelease TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStroke(int keyCode, int modifiers, - boolean onKeyRelease) { - - // Variables - KeyStroke key; - - key = new KeyStroke(); - key.keyCode = keyCode; - key.modifiers = modifiers; - key.onKeyRelease = onKeyRelease; - return key; - - } // getKeyStroke() - - /** - * getKeyStroke - * @param keyCode TODO - * @param modifiers TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStroke(int keyCode, int modifiers) { - return getKeyStroke(keyCode, modifiers, false); - } // getKeyStroke() - - /** - * getKeyStroke - * @param string TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStroke(String string) { - return null; // TODO - } // getKeyStroke() - - /** - * getKeyStrokeForEvent - * @param event TODO - * @returns KeyStroke - */ - public static KeyStroke getKeyStrokeForEvent(KeyEvent event) { - - // Variables - int eventID; - int eventMod; - - // Get Event ID - eventID = event.getID(); - eventMod = event.getModifiers(); - - // Check for KEY_TYPED event - if (eventID == KeyEvent.KEY_TYPED) { - return getKeyStroke(event.getKeyChar(), eventMod); - - // KEY_PRESSED or KEY_RELEASED event - } else { - return getKeyStroke(event.getKeyCode(), eventMod); - } // if - - } // getKeyStrokeForEvent() - - /** - * getKeyChar - * @returns char - */ - public char getKeyChar() { - return keyChar; - } // getKeyChar() - - /** - * getKeyCode - * @returns int - */ - public int getKeyCode() { - return keyCode; - } // getKeyCode() - - /** - * getModifiers - * @returns int - */ - public int getModifiers() { - return modifiers; // TODO - } // getModifiers() - - /** - * isOnKeyRelease - * @returns boolean - */ - public boolean isOnKeyRelease() { - return onKeyRelease; - } // isOnKeyRelease() - - -} // KeyStroke + private KeyStroke() { + } + + protected KeyStroke(char keyChar, int keyCode, int modifiers, + boolean onKeyRelease) + { + super(keyChar, keyCode, modifiers, onKeyRelease); + } + + static + { + AWTKeyStroke.registerSubclass(KeyStroke.class); + } + + public static KeyStroke getKeyStroke(char keyChar) + { + return (KeyStroke) getAWTKeyStroke(keyChar); + } + + /** + * @deprecated Use {@link #getKeyStroke(char)} + * + * This method, unlike all the other factory methods on this object, + * returns a non-cached, non-shared object. New code should not use it. + */ + public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) + { + return new KeyStroke(keyChar, KeyEvent.VK_UNDEFINED, 0, onKeyRelease); + } + + public static KeyStroke getKeyStroke(Character keyChar, int modifiers) + { + return (KeyStroke) getAWTKeyStroke(keyChar, modifiers); + } + + public static KeyStroke getKeyStroke(int keyCode, int modifiers, + boolean onKeyRelease) + { + return (KeyStroke) getAWTKeyStroke(keyCode, modifiers, onKeyRelease); + } + + public static KeyStroke getKeyStroke(int keyCode, int modifiers) + { + return (KeyStroke) getAWTKeyStroke(keyCode, modifiers); + } + + public static KeyStroke getKeyStroke(String str) + { + return (KeyStroke) getAWTKeyStroke(str); + } + + public static KeyStroke getKeyStrokeForEvent(KeyEvent event) + { + return (KeyStroke) getAWTKeyStrokeForEvent(event); + } + +} diff --git a/libjava/javax/swing/MutableComboBoxModel.java b/libjava/javax/swing/MutableComboBoxModel.java index 678aeaf6f76..2c0f4149d6a 100644 --- a/libjava/javax/swing/MutableComboBoxModel.java +++ b/libjava/javax/swing/MutableComboBoxModel.java @@ -38,40 +38,46 @@ exception statement from your version. */ package javax.swing; /** - * MutableComboBoxModel - * @author Andrew Selkirk - * @version 1.0 + * MutableComboBoxModel is interface for data model that keeps track of the + * components data and provides methods to insert and remove elements from + * it. The Classes implementing this interface should fire appropriate + * events indicating the undergoing change in the data model. + * + * @author Andrew Selkirk + * @author Olga Rodimina + * @version 1.0 */ -public interface MutableComboBoxModel extends ComboBoxModel { +public interface MutableComboBoxModel extends ComboBoxModel +{ + /** + * This method adds given object to its data model. + * + * @param object element to add to the data model. + */ + void addElement(Object object); - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * addElement - * @param object TODO - */ - void addElement(Object object); - - /** - * removeElementAt - * @param index TODO - */ - void removeElementAt(int index); - - /** - * insertElementAt - * @param object TODO - * @param index TODO - */ - void insertElementAt(Object object, int index); - - /** - * removeElement - * @param object TODO - */ - void removeElement(Object object); + /** + * This method removes elements located at the given index in the data + * model. + * + * @param index index specifying location of the element to remove. + */ + void removeElementAt(int index); + /** + * This method inserts givent element to the data model, at the specified + * index. + * + * @param object element to insert + * @param index index specifying the position in the data model where the + * given element should be inserted. + */ + void insertElementAt(Object object, int index); + /** + * This method removes given element from the data model + * + * @param element to remove. + */ + void removeElement(Object object); } // MutableComboBoxModel diff --git a/libjava/javax/swing/RepaintManager.java b/libjava/javax/swing/RepaintManager.java index 05b974f914c..8910bf58301 100644 --- a/libjava/javax/swing/RepaintManager.java +++ b/libjava/javax/swing/RepaintManager.java @@ -431,6 +431,9 @@ public class RepaintManager if (damaged.width == 0 || damaged.height == 0) continue; JRootPane root = comp.getRootPane(); + // If the component has no root, no repainting will occur. + if (root == null) + continue; Rectangle rootDamage = SwingUtilities.convertRectangle(comp, damaged, root); if (! roots.containsKey(root)) { @@ -450,7 +453,7 @@ public class RepaintManager Map.Entry ent = (Map.Entry) i.next(); JRootPane root = (JRootPane) ent.getKey(); Rectangle rect = (Rectangle) ent.getValue(); - root.paintImmediately(rect); + root.paintImmediately(rect); } } diff --git a/libjava/javax/swing/ScrollPaneLayout.java b/libjava/javax/swing/ScrollPaneLayout.java index 5e51e1895eb..1103f3f8b64 100644 --- a/libjava/javax/swing/ScrollPaneLayout.java +++ b/libjava/javax/swing/ScrollPaneLayout.java @@ -82,6 +82,8 @@ public class ScrollPaneLayout public void syncWithScrollPane(JScrollPane scrollPane) { viewport = scrollPane.getViewport(); + rowHead = scrollPane.getRowHeader(); + colHead = scrollPane.getColumnHeader(); vsb = scrollPane.getVerticalScrollBar(); hsb = scrollPane.getHorizontalScrollBar(); vsbPolicy = scrollPane.getVerticalScrollBarPolicy(); @@ -389,12 +391,12 @@ public class ScrollPaneLayout y4 = scrollPaneBounds.y + scrollPaneBounds.height; if (colHead != null) - y2 = colHead.getPreferredSize().height; + y2 = y1 + colHead.getPreferredSize().height; else y2 = y1; if (rowHead != null) - x2 = rowHead.getPreferredSize().width; + x2 = x1 + rowHead.getPreferredSize().width; else x2 = x1; diff --git a/libjava/javax/swing/SwingUtilities.java b/libjava/javax/swing/SwingUtilities.java index 62b156161f3..731a7bc8df7 100644 --- a/libjava/javax/swing/SwingUtilities.java +++ b/libjava/javax/swing/SwingUtilities.java @@ -51,9 +51,13 @@ import java.awt.Rectangle; import java.awt.Shape; import java.awt.Toolkit; import java.awt.Window; +import java.awt.event.ActionEvent; import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.lang.reflect.InvocationTargetException; +import javax.swing.plaf.ActionMapUIResource; +import javax.swing.plaf.InputMapUIResource; /** @@ -441,7 +445,7 @@ public class SwingUtilities implements SwingConstants destination); return new MouseEvent(destination, sourceEvent.getID(), - sourceEvent.getWhen(), sourceEvent.getModifiers(), + sourceEvent.getWhen(), sourceEvent.getModifiersEx(), newpt.x, newpt.y, sourceEvent.getClickCount(), sourceEvent.isPopupTrigger(), sourceEvent.getButton()); } @@ -863,7 +867,7 @@ public class SwingUtilities implements SwingConstants */ public static boolean isLeftMouseButton(MouseEvent event) { - return ((event.getModifiers() & InputEvent.BUTTON1_DOWN_MASK) + return ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK); } @@ -876,7 +880,7 @@ public class SwingUtilities implements SwingConstants */ public static boolean isMiddleMouseButton(MouseEvent event) { - return ((event.getModifiers() & InputEvent.BUTTON2_DOWN_MASK) + return ((event.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK); } @@ -889,7 +893,7 @@ public class SwingUtilities implements SwingConstants */ public static boolean isRightMouseButton(MouseEvent event) { - return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK) + return ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK); } @@ -911,4 +915,103 @@ public class SwingUtilities implements SwingConstants return true; } } + + public static boolean notifyAction(Action action, + KeyStroke ks, + KeyEvent event, + Object sender, + int modifiers) + { + if (action != null && action.isEnabled()) + { + String name = (String) action.getValue(Action.ACTION_COMMAND_KEY); + if (name == null + && event.getKeyChar() != KeyEvent.CHAR_UNDEFINED) + name = new String(new char[] {event.getKeyChar()}); + action.actionPerformed(new ActionEvent(sender, + ActionEvent.ACTION_PERFORMED, + name, modifiers)); + return true; + } + return false; + } + + /** + *

    Change the shared, UI-managed {@link ActionMap} for a given + * component. ActionMaps are arranged in a hierarchy, in order to + * encourage sharing of common actions between components. The hierarchy + * unfortunately places UI-managed ActionMaps at the end of the + * parent-pointer chain, as illustrated:

    + * + *
    +   *  [{@link javax.swing.JComponent#getActionMap()}] 
    +   *          --> [{@link javax.swing.ActionMap}] 
    +   *     parent --> [{@link javax.swing.text.KeymapActionMap}] 
    +   *       parent --> [{@link javax.swing.plaf.ActionMapUIResource}]
    +   * 
    + * + *

    Our goal with this method is to replace the first ActionMap along + * this chain which is an instance of {@link ActionMapUIResource}, since + * these are the ActionMaps which are supposed to be shared between + * components.

    + * + *

    If the provided ActionMap is null, we interpret the + * call as a request to remove the UI-managed ActionMap from the + * component's ActionMap parent chain.

    + */ + public static void replaceUIActionMap(JComponent component, + ActionMap uiActionMap) + { + ActionMap child = component.getActionMap(); + if (child == null) + component.setActionMap(uiActionMap); + else + { + while(child.getParent() != null + && !(child.getParent() instanceof ActionMapUIResource)) + child = child.getParent(); + if (child != null) + child.setParent(uiActionMap); + } + } + + /** + *

    Change the shared, UI-managed {@link InputMap} for a given + * component. InputMaps are arranged in a hierarchy, in order to + * encourage sharing of common input mappings between components. The + * hierarchy unfortunately places UI-managed InputMaps at the + * end of the parent-pointer chain, as illustrated:

    + * + *
    +   *  [{@link javax.swing.JComponent#getInputMap()}] 
    +   *          --> [{@link javax.swing.InputMap}] 
    +   *     parent --> [{@link javax.swing.text.KeymapWrapper}] 
    +   *       parent --> [{@link javax.swing.plaf.InputMapUIResource}]
    +   * 
    + * + *

    Our goal with this method is to replace the first InputMap along + * this chain which is an instance of {@link InputMapUIResource}, since + * these are the InputMaps which are supposed to be shared between + * components.

    + * + *

    If the provided InputMap is null, we interpret the + * call as a request to remove the UI-managed InputMap from the + * component's InputMap parent chain.

    + */ + public static void replaceUIInputMap(JComponent component, + int condition, + InputMap uiInputMap) + { + InputMap child = component.getInputMap(condition); + if (child == null) + component.setInputMap(condition, uiInputMap); + else + { + while(child.getParent() != null + && !(child.getParent() instanceof InputMapUIResource)) + child = child.getParent(); + if (child != null) + child.setParent(uiInputMap); + } + } } diff --git a/libjava/javax/swing/Timer.java b/libjava/javax/swing/Timer.java index 2b2920a1827..529ad19348c 100644 --- a/libjava/javax/swing/Timer.java +++ b/libjava/javax/swing/Timer.java @@ -1,4 +1,4 @@ -/* Timer.java -- +/* Timer.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,22 +35,26 @@ 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 javax.swing; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.Serializable; import java.util.EventListener; - import javax.swing.event.EventListenerList; + +/** + * DOCUMENT ME! + */ public class Timer implements Serializable { + /** DOCUMENT ME! */ private static final long serialVersionUID = -1116180831621385484L; - + + /** DOCUMENT ME! */ protected EventListenerList listenerList = new EventListenerList(); - + // This object manages a "queue" of virtual actionEvents, maintained as a // simple long counter. When the timer expires, a new event is queued, // and a dispatcher object is pushed into the system event queue. When @@ -58,79 +62,127 @@ public class Timer implements Serializable // ActionEvents as have been queued, unless the timer is set to // coalescing mode, in which case it will fire only one ActionEvent. + /** DOCUMENT ME! */ private long queue; + + /** DOCUMENT ME! */ private Object queueLock = new Object(); + + /** DOCUMENT ME! */ + private Waker waker; + + /** + * DOCUMENT ME! + */ private void queueEvent() { synchronized (queueLock) { - queue++; - if (queue == 1) - SwingUtilities.invokeLater(new Runnable() { public void run() { drainEvents(); } }); + queue++; + if (queue == 1) + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + drainEvents(); + } + }); + } } + /** + * DOCUMENT ME! + */ private void drainEvents() { synchronized (queueLock) { - if (isCoalesce()) - { - if (queue > 0) - fireActionPerformed(); - } - else - { - while(queue > 0) - { - fireActionPerformed(); - queue--; - } - } - queue = 0; + if (isCoalesce()) + { + if (queue > 0) + fireActionPerformed(); + } + else + { + while (queue > 0) + { + fireActionPerformed(); + queue--; + } + } + queue = 0; } } - static boolean logTimers; + + /** DOCUMENT ME! */ boolean coalesce = true; + + /** DOCUMENT ME! */ boolean repeats = true; + + /** DOCUMENT ME! */ boolean running; + + /** DOCUMENT ME! */ int ticks; + + /** DOCUMENT ME! */ int delay; + + /** DOCUMENT ME! */ int initialDelay; - - private class Waker - extends Thread + + /** + * DOCUMENT ME! + */ + private class Waker extends Thread { + /** + * DOCUMENT ME! + */ public void run() { running = true; - try + try { - - sleep(initialDelay); - - while (running) - { - sleep(delay); - queueEvent(); - - if (logTimers) - System.out.println("javax.swing.Timer -> clocktick"); - - if (! repeats) - break; - } - running = false; - } - catch (Exception e) + sleep(initialDelay); + + while (running) + { + try + { + sleep(delay); + } + catch (InterruptedException e) + { + return; + } + queueEvent(); + + if (logTimers) + System.out.println("javax.swing.Timer -> clocktick"); + + if (! repeats) + break; + } + running = false; + } + catch (Exception e) { - System.out.println("swing.Timer::" + e); +// System.out.println("swing.Timer::" + e); } } } + /** + * Creates a new Timer object. + * + * @param d DOCUMENT ME! + * @param listener DOCUMENT ME! + */ public Timer(int d, ActionListener listener) { delay = d; @@ -139,123 +191,214 @@ public class Timer implements Serializable addActionListener(listener); } + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + */ public void setCoalesce(boolean c) { coalesce = c; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public boolean isCoalesce() { return coalesce; } + /** + * DOCUMENT ME! + * + * @param listener DOCUMENT ME! + */ public void addActionListener(ActionListener listener) { - listenerList.add (ActionListener.class, listener); + listenerList.add(ActionListener.class, listener); } - + + /** + * DOCUMENT ME! + * + * @param listener DOCUMENT ME! + */ public void removeActionListener(ActionListener listener) { - listenerList.remove (ActionListener.class, listener); + listenerList.remove(ActionListener.class, listener); } /** + * DOCUMENT ME! + * + * @param listenerType DOCUMENT ME! + * + * @return DOCUMENT ME! + * * @since 1.3 */ - public EventListener[] getListeners (Class listenerType) + public EventListener[] getListeners(Class listenerType) { - return listenerList.getListeners (listenerType); + return listenerList.getListeners(listenerType); } - + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + * * @since 1.4 */ - public ActionListener[] getActionListeners () + public ActionListener[] getActionListeners() { - return (ActionListener[]) listenerList.getListeners (ActionListener.class); + return (ActionListener[]) listenerList.getListeners(ActionListener.class); } - protected void fireActionPerformed (ActionEvent event) + /** + * DOCUMENT ME! + * + * @param event DOCUMENT ME! + */ + protected void fireActionPerformed(ActionEvent event) { ActionListener[] listeners = getActionListeners(); - + for (int i = 0; i < listeners.length; i++) - { - listeners [i].actionPerformed (event); - } + listeners[i].actionPerformed(event); } - void fireActionPerformed () + /** + * DOCUMENT ME! + */ + void fireActionPerformed() { - fireActionPerformed (new ActionEvent (this, ticks++, "Timer")); + fireActionPerformed(new ActionEvent(this, ticks++, "Timer")); } + /** + * DOCUMENT ME! + * + * @param lt DOCUMENT ME! + */ public static void setLogTimers(boolean lt) { logTimers = lt; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public static boolean getLogTimers() { return logTimers; } - + + /** + * DOCUMENT ME! + * + * @param d DOCUMENT ME! + */ public void setDelay(int d) { delay = d; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getDelay() { return delay; } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ public void setInitialDelay(int i) { initialDelay = i; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getInitialDelay() { return initialDelay; } + /** + * DOCUMENT ME! + * + * @param r DOCUMENT ME! + */ public void setRepeats(boolean r) { repeats = r; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public boolean isRepeats() { return repeats; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public boolean isRunning() { return running; } + /** + * DOCUMENT ME! + */ public void start() { if (isRunning()) - { - System.err.println("attempt to start a running timer"); - return; - } - new Waker().start(); + return; + waker = new Waker(); + waker.start(); } + /** + * DOCUMENT ME! + */ public void restart() { - synchronized (queueLock) - { - queue = 0; - } + stop(); start(); } + /** + * DOCUMENT ME! + */ public void stop() { running = false; + if (waker != null) + waker.interrupt(); + synchronized (queueLock) + { + queue = 0; + } } } diff --git a/libjava/javax/swing/ToolTipManager.java b/libjava/javax/swing/ToolTipManager.java index 3a855f708c4..3556ef005a6 100644 --- a/libjava/javax/swing/ToolTipManager.java +++ b/libjava/javax/swing/ToolTipManager.java @@ -37,315 +37,608 @@ exception statement from your version. */ package javax.swing; +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; +import javax.swing.JComponent; +import javax.swing.Popup; +import javax.swing.PopupFactory; +import javax.swing.SwingUtilities; +import javax.swing.Timer; /** - * ToolTipManager - * - * @author Andrew Selkirk + * This class is responsible for the registration of JToolTips to Components + * and for displaying them when appropriate. */ -public class ToolTipManager extends MouseAdapter - implements MouseMotionListener +public class ToolTipManager extends MouseAdapter implements MouseMotionListener { - /** - * stillInsideTimerAction - */ - protected class stillInsideTimerAction - implements ActionListener + /** + * This ActionListener is associated with the Timer that listens to whether + * the JToolTip can be hidden after four seconds. + */ + protected class stillInsideTimerAction implements ActionListener { - /** - * Constructor stillInsideTimerAction - */ + /** + * This method creates a new stillInsideTimerAction object. + */ protected stillInsideTimerAction() { - // TODO } - /** - * actionPerformed - * @param event TODO - */ + /** + * This method hides the JToolTip when the Timer has finished. + * + * @param event The ActionEvent. + */ public void actionPerformed(ActionEvent event) { - // TODO + hideTip(); } } - /** - * outsideTimerAction - */ - protected class outsideTimerAction - implements ActionListener + /** + * This Actionlistener is associated with the Timer that listens to whether + * the mouse cursor has re-entered the JComponent in time for an immediate + * redisplay of the JToolTip. + */ + protected class outsideTimerAction implements ActionListener { - /** - * Constructor outsideTimerAction - */ + /** + * This method creates a new outsideTimerAction object. + */ protected outsideTimerAction() { - // TODO } - /** - * actionPerformed - * @param value0 TODO - */ + /** + * This method is called when the Timer that listens to whether the mouse + * cursor has re-entered the JComponent has run out. + * + * @param event The ActionEvent. + */ public void actionPerformed(ActionEvent event) { - // TODO } } - /** - * insideTimerAction - */ - protected class insideTimerAction - implements ActionListener + /** + * This ActionListener is associated with the Timer that listens to whether + * it is time for the JToolTip to be displayed after the mouse has entered + * the JComponent. + */ + protected class insideTimerAction implements ActionListener { - /** - * Constructor insideTimerAction - */ + /** + * This method creates a new insideTimerAction object. + */ protected insideTimerAction() { - // TODO } - /** - * actionPerformed - * @param event TODO - */ + /** + * This method displays the JToolTip when the Mouse has been still for the + * delay. + * + * @param event The ActionEvent. + */ public void actionPerformed(ActionEvent event) { - // TODO + showTip(); + if (insideTimer != null) + insideTimer.start(); } } - /** - * enterTimer - */ - Timer enterTimer; - - /** - * exitTimer - */ - Timer exitTimer; - - /** - * insideTimer - */ - Timer insideTimer; - - /** - * toolTipText - */ - String toolTipText; - - /** - * mouseEvent - */ - MouseEvent mouseEvent; - - /** - * showImmediately - */ - boolean showImmediately; - - /** - * tip - */ - JToolTip tip; - - /** - * enabled - */ - boolean enabled; - - /** - * timerEnter - */ - private long timerEnter; - - /** - * lightWeightPopupEnabled - */ - protected boolean lightWeightPopupEnabled; - - /** - * heavyWeightPopupEnabled - */ - protected boolean heavyWeightPopupEnabled; - - /** - * Constructor ToolTipManager - */ + /** + * The Timer that determines whether the Mouse has been still long enough + * for the JToolTip to be displayed. + */ + Timer enterTimer; + + /** + * The Timer that determines whether the Mouse has re-entered the JComponent + * quickly enough for the JToolTip to be displayed immediately. + */ + Timer exitTimer; + + /** + * The Timer that determines whether the JToolTip has been displayed long + * enough for it to be hidden. + */ + Timer insideTimer; + + /** A global enabled setting for the ToolTipManager. */ + private transient boolean enabled = true; + + /** lightWeightPopupEnabled */ + protected boolean lightWeightPopupEnabled = true; + + /** heavyWeightPopupEnabled */ + protected boolean heavyWeightPopupEnabled = false; + + /** The shared instance of the ToolTipManager. */ + private static ToolTipManager shared; + + /** The current component the tooltip is being displayed for. */ + private static Component currentComponent; + + /** The current tooltip. */ + private static JToolTip currentTip; + + /** The last known position of the mouse cursor. */ + private static Point currentPoint; + + /** + * The panel that holds the tooltip when the tooltip is displayed fully + * inside the current container. + */ + private static Container containerPanel; + + /** + * The window used when the tooltip doesn't fit inside the current + * container. + */ + private static JWindow tooltipWindow; + + /** + * Creates a new ToolTipManager and sets up the timers. + */ ToolTipManager() { - // TODO + enterTimer = new Timer(750, new insideTimerAction()); + enterTimer.setRepeats(false); + + insideTimer = new Timer(4000, new stillInsideTimerAction()); + insideTimer.setRepeats(false); + + exitTimer = new Timer(500, new outsideTimerAction()); + exitTimer.setRepeats(false); } - /** - * sharedInstance - * @return ToolTipManager - */ + /** + * This method returns the shared instance of ToolTipManager used by all + * JComponents. + * + * @return The shared instance of ToolTipManager. + */ public static ToolTipManager sharedInstance() { - return null; // TODO + if (shared == null) + shared = new ToolTipManager(); + + return shared; } - /** - * setEnabled - * @param enabled TODO - */ + /** + * This method sets whether ToolTips are enabled or disabled for all + * JComponents. + * + * @param enabled Whether ToolTips are enabled or disabled for all + * JComponents. + */ public void setEnabled(boolean enabled) { - // TODO + if (! enabled) + { + enterTimer.stop(); + exitTimer.stop(); + insideTimer.stop(); + } + + this.enabled = enabled; } - /** - * isEnabled - * @return boolean - */ + /** + * This method returns whether ToolTips are enabled. + * + * @return Whether ToolTips are enabled. + */ public boolean isEnabled() { - return false; // TODO + return enabled; } - /** - * isLightWeightPopupEnabled - * @return boolean - */ + /** + * This method returns whether LightweightToolTips are enabled. + * + * @return Whether LighweightToolTips are enabled. + */ public boolean isLightWeightPopupEnabled() { - return false; // TODO + return lightWeightPopupEnabled; } - /** - * setLightWeightPopupEnabled - * @param enabled TODO - */ + /** + * This method sets whether LightweightToolTips are enabled. If you mix + * Lightweight and Heavyweight components, you must set this to false to + * ensure that the ToolTips popup above all other components. + * + * @param enabled Whether LightweightToolTips will be enabled. + */ public void setLightWeightPopupEnabled(boolean enabled) { - // TODO + lightWeightPopupEnabled = enabled; + heavyWeightPopupEnabled = ! enabled; } - /** - * getInitialDelay - * @return int - */ + /** + * This method returns the initial delay before the ToolTip is shown when + * the mouse enters a Component. + * + * @return The initial delay before the ToolTip is shown. + */ public int getInitialDelay() { - return 0; // TODO + return enterTimer.getDelay(); } - /** - * setInitialDelay - * @param delay TODO - */ + /** + * This method sets the initial delay before the ToolTip is shown when the + * mouse enters a Component. + * + * @param delay The initial delay before the ToolTip is shown. + */ public void setInitialDelay(int delay) { - // TODO + enterTimer.setDelay(delay); } - /** - * getDismissDelay - * @return int - */ + /** + * This method returns the time the ToolTip will be shown before being + * hidden. + * + * @return The time the ToolTip will be shown before being hidden. + */ public int getDismissDelay() { - return 0; // TODO + return insideTimer.getDelay(); } - /** - * setDismissDelay - * @param delay TODO - */ + /** + * This method sets the time the ToolTip will be shown before being hidden. + * + * @param delay The time the ToolTip will be shown before being hidden. + */ public void setDismissDelay(int delay) { - // TODO + insideTimer.setDelay(delay); } - /** - * getReshowDelay - * @return int - */ + /** + * This method returns the amount of delay where if the mouse re-enters a + * Component, the tooltip will be shown immediately. + * + * @return The reshow delay. + */ public int getReshowDelay() { - return 0; // TODO + return exitTimer.getDelay(); } - /** - * setReshowDelay - * @param delay TODO - */ + /** + * This method sets the amount of delay where if the mouse re-enters a + * Component, the tooltip will be shown immediately. + * + * @param delay The reshow delay. + */ public void setReshowDelay(int delay) { - // TODO + exitTimer.setDelay(delay); } - /** - * registerComponent - * @param component TODO - */ + /** + * This method registers a JComponent with the ToolTipManager. + * + * @param component The JComponent to register with the ToolTipManager. + */ public void registerComponent(JComponent component) { - // TODO + component.addMouseListener(this); + component.addMouseMotionListener(this); } - /** - * unregisterComponent - * @param component TODO - */ + /** + * This method unregisters a JComponent with the ToolTipManager. + * + * @param component The JComponent to unregister with the ToolTipManager. + */ public void unregisterComponent(JComponent component) { - // TODO + component.removeMouseMotionListener(this); + component.removeMouseListener(this); } - /** - * mouseEntered - * @param event TODO - */ + /** + * This method is called whenever the mouse enters a JComponent registered + * with the ToolTipManager. When the mouse enters within the period of time + * specified by the reshow delay, the tooltip will be displayed + * immediately. Otherwise, it must wait for the initial delay before + * displaying the tooltip. + * + * @param event The MouseEvent. + */ public void mouseEntered(MouseEvent event) { - // TODO + if (currentComponent != null + && getContentPaneDeepestComponent(event) == currentComponent) + return; + currentPoint = event.getPoint(); + currentComponent = (Component) event.getSource(); + + if (exitTimer.isRunning()) + { + exitTimer.stop(); + showTip(); + insideTimer.start(); + return; + } + + // This should always be stopped unless we have just fake-exited. + if (! enterTimer.isRunning()) + enterTimer.start(); } - /** - * mouseExited - * @param event TODO - */ + /** + * This method is called when the mouse exits a JComponent registered with + * the ToolTipManager. When the mouse exits, the tooltip should be hidden + * immediately. + * + * @param event The MouseEvent. + */ public void mouseExited(MouseEvent event) { - // TODO + if (getContentPaneDeepestComponent(event) == currentComponent) + return; + + currentPoint = event.getPoint(); + currentComponent = null; + hideTip(); + + if (! enterTimer.isRunning() && insideTimer.isRunning()) + exitTimer.start(); + if (enterTimer.isRunning()) + enterTimer.stop(); + if (insideTimer.isRunning()) + insideTimer.stop(); } - /** - * mousePressed - * @param event TODO - */ + /** + * This method is called when the mouse is pressed on a JComponent + * registered with the ToolTipManager. When the mouse is pressed, the + * tooltip (if it is shown) must be hidden immediately. + * + * @param event The MouseEvent. + */ public void mousePressed(MouseEvent event) { - // TODO + currentPoint = event.getPoint(); + if (enterTimer.isRunning()) + enterTimer.restart(); + else if (insideTimer.isRunning()) + { + insideTimer.stop(); + hideTip(); + } + currentComponent.invalidate(); + currentComponent.validate(); + currentComponent.repaint(); } - /** - * mouseDragged - * @param event TODO - */ + /** + * This method is called when the mouse is dragged in a JComponent + * registered with the ToolTipManager. + * + * @param event The MouseEvent. + */ public void mouseDragged(MouseEvent event) { - // TODO + currentPoint = event.getPoint(); + if (enterTimer.isRunning()) + enterTimer.restart(); } - /** - * mouseMoved - * @param event TODO - */ + /** + * This method is called when the mouse is moved in a JComponent registered + * with the ToolTipManager. + * + * @param event The MouseEvent. + */ public void mouseMoved(MouseEvent event) { - // TODO + currentPoint = event.getPoint(); + if (currentTip != null) + currentTip.setTipText(((JComponent) currentComponent).getToolTipText(event)); + if (enterTimer.isRunning()) + enterTimer.restart(); + } + + /** + * This method displays the ToolTip. It can figure out the method needed to + * show it as well (whether to display it in heavyweight/lightweight panel + * or a window.) + */ + private void showTip() + { + if (! enabled) + return; + + if (currentTip == null + || currentTip.getComponent() != currentComponent + && currentComponent instanceof JComponent) + currentTip = ((JComponent) currentComponent).createToolTip(); + Point p = currentPoint; + Dimension dims = currentTip.getPreferredSize(); + if (canToolTipFit(currentTip)) + { + JLayeredPane pane = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class, + currentComponent)) + .getLayeredPane(); + + // This should never happen, but just in case. + if (pane == null) + return; + + if (containerPanel != null) + hideTip(); + if (isLightWeightPopupEnabled()) + { + containerPanel = new Panel(); + JRootPane root = new JRootPane(); + root.getContentPane().add(currentTip); + containerPanel.add(root); + } + else + { + containerPanel = new JPanel(); + containerPanel.add(currentTip); + } + LayoutManager lm = containerPanel.getLayout(); + if (lm instanceof FlowLayout) + { + FlowLayout fm = (FlowLayout) lm; + fm.setVgap(0); + fm.setHgap(0); + } + + p = getGoodPoint(p, pane, currentTip, dims); + + pane.add(containerPanel); + containerPanel.setBounds(p.x, p.y, dims.width, dims.height); + currentTip.setBounds(0, 0, dims.width, dims.height); + + pane.revalidate(); + pane.repaint(); + } + else + { + SwingUtilities.convertPointToScreen(p, currentComponent); + tooltipWindow = new JWindow(); + tooltipWindow.getContentPane().add(currentTip); + tooltipWindow.setFocusable(false); + tooltipWindow.pack(); + tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height); + tooltipWindow.show(); + } + currentTip.setVisible(true); + } + + /** + * This method hides the ToolTip. + */ + private void hideTip() + { + if (currentTip == null || ! currentTip.isVisible() || ! enabled) + return; + currentTip.setVisible(false); + if (containerPanel != null) + { + Container parent = containerPanel.getParent(); + if (parent == null) + return; + parent.remove(containerPanel); + parent.invalidate(); + parent.validate(); + parent.repaint(); + + parent = currentTip.getParent(); + if (parent == null) + return; + parent.remove(currentTip); + + containerPanel = null; + } + if (tooltipWindow != null) + { + tooltipWindow.hide(); + tooltipWindow.dispose(); + tooltipWindow = null; + } + } + + /** + * This method returns a point in the LayeredPane where the ToolTip can be + * shown. The point returned (if the ToolTip is to be displayed at the + * preferred dimensions) will always place the ToolTip inside the + * currentComponent if possible. + * + * @param p The last known good point for the mouse. + * @param c The JLayeredPane in the first RootPaneContainer up from the + * currentComponent. + * @param tip The ToolTip to display. + * @param dims The ToolTip preferred dimensions (can be null). + * + * @return A good point to place the ToolTip. + */ + private Point getGoodPoint(Point p, JLayeredPane c, JToolTip tip, + Dimension dims) + { + if (dims == null) + dims = tip.getPreferredSize(); + Rectangle bounds = currentComponent.getBounds(); + if (p.x + dims.width > bounds.width) + p.x = bounds.width - dims.width; + if (p.y + dims.height > bounds.height) + p.y = bounds.height - dims.height; + + p = SwingUtilities.convertPoint(currentComponent, p, c); + return p; + } + + /** + * This method returns the deepest component in the content pane for the + * first RootPaneContainer up from the currentComponent. This method is + * used in conjunction with one of the mouseXXX methods. + * + * @param e The MouseEvent. + * + * @return The deepest component in the content pane. + */ + private Component getContentPaneDeepestComponent(MouseEvent e) + { + Component source = (Component) e.getSource(); + Container parent = (Container) SwingUtilities.getAncestorOfClass(JRootPane.class, + currentComponent); + if (parent == null) + return null; + parent = ((JRootPane) parent).getContentPane(); + Point p = e.getPoint(); + p = SwingUtilities.convertPoint(source, p, parent); + Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y); + return target; + } + + /** + * This method returns whether the ToolTip can fit in the first + * RootPaneContainer up from the currentComponent. + * + * @param tip The ToolTip. + * + * @return Whether the ToolTip can fit. + */ + private boolean canToolTipFit(JToolTip tip) + { + JRootPane root = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class, + currentComponent); + if (root == null) + return false; + Dimension pref = tip.getPreferredSize(); + Dimension rootSize = root.getSize(); + if (rootSize.width > pref.width && rootSize.height > pref.height) + return true; + return false; } } diff --git a/libjava/javax/swing/UIManager.java b/libjava/javax/swing/UIManager.java index eca96f91078..a600972aff3 100644 --- a/libjava/javax/swing/UIManager.java +++ b/libjava/javax/swing/UIManager.java @@ -278,7 +278,7 @@ public class UIManager implements Serializable } /** - * Returns the L&F object that renders the target component. + * Returns the Look and Feel object that renders the target component. */ public static ComponentUI getUI(JComponent target) { diff --git a/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java b/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java index 3fa0ad1945f..37d6276988e 100644 --- a/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java +++ b/libjava/javax/swing/colorchooser/AbstractColorChooserPanel.java @@ -35,7 +35,6 @@ 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 javax.swing.colorchooser; import java.awt.Color; @@ -44,92 +43,119 @@ import javax.swing.Icon; import javax.swing.JColorChooser; import javax.swing.JPanel; + /** * AbstractColorChooserPanel - * @author Andrew Selkirk - * @version 1.0 + * + * @author Andrew Selkirk + * @version 1.0 */ public abstract class AbstractColorChooserPanel extends JPanel { + /** DOCUMENT ME! */ private static final long serialVersionUID = -977469671210173863L; - /** - * chooser - */ - private JColorChooser chooser; - - /** - * Constructor AbstractColorChooserPanel - */ - public AbstractColorChooserPanel() { - // TODO - } // AbstractColorChooserPanel() - - /** - * getDisplayName - * @returns String - */ - public abstract String getDisplayName(); - - /** - * updateChooser - */ - public abstract void updateChooser(); - - /** - * buildChooser - */ - protected abstract void buildChooser(); - - /** - * getSmallDisplayIcon - * @returns Icon - */ - public abstract Icon getSmallDisplayIcon(); - - /** - * getLargeDisplayIcon - * @returns Icon - */ - public abstract Icon getLargeDisplayIcon(); - - /** - * installChooserPanel - * @param chooser TODO - */ - public void installChooserPanel(JColorChooser chooser) { - // TODO - } // installChooserPanel() - - /** - * uninstallChooserPanel - * @param chooser TODO - */ - public void uninstallChooserPanel(JColorChooser chooser) { - // TODO - } // uninstallChooserPanel() - - /** - * getColorSelectionModel - * @returns ColorSelectionModel - */ - public ColorSelectionModel getColorSelectionModel() { - return null; // TODO - } // getColorSelectionModel() - - /** - * getColorFromModel - * @returns Color - */ - protected Color getColorFromModel() { - return null; // TODO - } // getColorFromModel() - - /** - * paint - * @param graphics TODO - */ - public void paint(Graphics graphics) { - // TODO - } // paint() + /** The chooser associated with this panel. */ + private JColorChooser chooser; + + /** + * This is the constructor for the AbstractColorChooserPanel. + */ + public AbstractColorChooserPanel() + { + } // AbstractColorChooserPanel() + + /** + * This method returns the name displayed in the tab for this chooser panel. + * + * @return The name displayed in the JTabbedPane's tabs. + */ + public abstract String getDisplayName(); + + /** + * This method updates the chooser panel when the JColorChooser's color has + * changed. + */ + public abstract void updateChooser(); + + /** + * This method constructs and does any initialization necessary for the + * chooser panel. + */ + protected abstract void buildChooser(); + + /** + * This method sets the small icon used in the JTabbedPane for this chooser + * panel. + * + * @return The small icon used in the JTabbedPane. + */ + public abstract Icon getSmallDisplayIcon(); + + /** + * This method sets the large icon useed in the jTabbedPane for this chooser + * panel. + * + * @return The large icon. + */ + public abstract Icon getLargeDisplayIcon(); + + /** + * This method installs the chooser panel for the given JColorChooser. + * + * @param chooser The JColorChooser that will have this panel installed. + */ + public void installChooserPanel(JColorChooser chooser) + { + this.chooser = chooser; + buildChooser(); + } // installChooserPanel() + + /** + * This method removes the chooser panel from the given JColorChooser and + * does any necessary clean up for the chooser panel. + * + * @param chooser The JColorChooser that is having this panel removed. + */ + public void uninstallChooserPanel(JColorChooser chooser) + { + this.chooser = null; + } // uninstallChooserPanel() + + /** + * This method returns the ColorSelectionModel for the JColorChooser + * associated with this chooser panel. + * + * @return The ColorSelectionModel for the JColorChooser associated with + * this chooser panel. + */ + public ColorSelectionModel getColorSelectionModel() + { + if (chooser != null) + return chooser.getSelectionModel(); + return null; + } // getColorSelectionModel() + + /** + * This method returns the current color stored in the model for this + * chooser panel. + * + * @return The current color. + */ + protected Color getColorFromModel() + { + if (chooser != null) + return chooser.getColor(); + return null; + } // getColorFromModel() + + /** + * This method paints the chooser panel. + * + * @param graphics The Graphics object to paint with. + */ + public void paint(Graphics graphics) + { + super.paint(graphics); + } // paint() } // AbstractColorChooserPanel diff --git a/libjava/javax/swing/colorchooser/ColorChooserComponentFactory.java b/libjava/javax/swing/colorchooser/ColorChooserComponentFactory.java index ffd8718eac0..6e7ca33d752 100644 --- a/libjava/javax/swing/colorchooser/ColorChooserComponentFactory.java +++ b/libjava/javax/swing/colorchooser/ColorChooserComponentFactory.java @@ -35,49 +35,51 @@ 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 javax.swing.colorchooser; import javax.swing.JComponent; + /** * ColorChooserComponentFactory - * @author Andrew Selkirk - * @version 1.0 + * + * @author Andrew Selkirk + * @version 1.0 */ -public class ColorChooserComponentFactory { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor ColorChooserComponentFactory - */ - private ColorChooserComponentFactory() { - // TODO - } // ColorChooserComponentFactory() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getDefaultChooserPanels - * @returns AbstractColorChooserPanel[] - */ - public static AbstractColorChooserPanel[] getDefaultChooserPanels() { - return null; // TODO - } // getDefaultChooserPanels() - - /** - * getPreviewPanel - * @returns JComponent - */ - public static JComponent getPreviewPanel() { - return null; // TODO - } // getPreviewPanel() - - +public class ColorChooserComponentFactory +{ + /** + * Constructor ColorChooserComponentFactory + */ + private ColorChooserComponentFactory() + { + } // ColorChooserComponentFactory() + + /** + * This method returns the three default chooser panels to be used in + * JColorChooser. + * + * @return The default chooser panels. + */ + public static AbstractColorChooserPanel[] getDefaultChooserPanels() + { + AbstractColorChooserPanel[] values = + { + new DefaultSwatchChooserPanel(), + new DefaultHSBChooserPanel(), + new DefaultRGBChooserPanel() + }; + return values; + } + + /** + * This method returns the default preview panel to be used with + * JColorChoosers. + * + * @return The default preview panel. + */ + public static JComponent getPreviewPanel() + { + return new DefaultPreviewPanel(); + } // getPreviewPanel() } // ColorChooserComponentFactory diff --git a/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java b/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java index 43df7edffb9..90145edced8 100644 --- a/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java +++ b/libjava/javax/swing/colorchooser/DefaultColorSelectionModel.java @@ -35,7 +35,6 @@ 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 javax.swing.colorchooser; import java.awt.Color; @@ -44,43 +43,55 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; + /** - * DefaultColorSelectionModel - * @author Andrew Selkirk - * @version 1.0 + * This is the default implementation of the ColorSelectionModel interface + * that JColorChoosers use. + * + * @author Andrew Selkirk + * @version 1.0 */ -public class DefaultColorSelectionModel - implements ColorSelectionModel, Serializable +public class DefaultColorSelectionModel implements ColorSelectionModel, + Serializable { + /** DOCUMENT ME! */ private static final long serialVersionUID = -8117143602864778804L; + /** The currently selected color. */ private Color selectedColor; - protected transient ChangeEvent changeEvent = new ChangeEvent (this); - protected EventListenerList listenerList = new EventListenerList (); + /** The ChangeEvent fired to all ChangeListeners. */ + protected transient ChangeEvent changeEvent = new ChangeEvent(this); + + /** The list of listeners. */ + protected EventListenerList listenerList = new EventListenerList(); /** - * Creates a new color selection model. + * Creates a new color selection model with the default white color. */ public DefaultColorSelectionModel() { - this (Color.white); + this(Color.white); } /** * Creates a new color selection model with a given selected color. - * - * @param color The selected color. + * + * @param color The initial color. + * + * @throws Error If the color is null. */ - public DefaultColorSelectionModel (Color color) + public DefaultColorSelectionModel(Color color) { super(); + if (color == null) + throw new Error("ColorSelectionModel cannot be set to have null color."); this.selectedColor = color; } /** * Returns the selected color. - * + * * @return The selected color. */ public Color getSelectedColor() @@ -89,31 +100,41 @@ public class DefaultColorSelectionModel } /** + * This method sets the color. + * * @param color The color to set. + * + * @throws Error If the color is set. */ - public void setSelectedColor (Color color) + public void setSelectedColor(Color color) { - this.selectedColor = color; + if (color == null) + throw new Error("ColorSelectionModel cannot be set to have null color."); + if (color != selectedColor) + { + this.selectedColor = color; + fireStateChanged(); + } } /** * Adds a listener to this model. - * + * * @param listener The listener to add. */ - public void addChangeListener (ChangeListener listener) + public void addChangeListener(ChangeListener listener) { - listenerList.add (ChangeListener.class, listener); + listenerList.add(ChangeListener.class, listener); } /** * Removes a listener from this model. - * + * * @param listener The listener to remove. */ - public void removeChangeListener (ChangeListener listener) + public void removeChangeListener(ChangeListener listener) { - listenerList.remove (ChangeListener.class, listener); + listenerList.remove(ChangeListener.class, listener); } /** @@ -123,19 +144,19 @@ public class DefaultColorSelectionModel */ public ChangeListener[] getChangeListeners() { - return (ChangeListener[]) listenerList.getListeners (ChangeListener.class); + return (ChangeListener[]) listenerList.getListeners(ChangeListener.class); } /** * Calls all the stateChanged() method of all added - * ChangeListener objects with changeEvent - * as argument. + * ChangeListener objects with changeEvent as + * argument. */ protected void fireStateChanged() { ChangeListener[] listeners = getChangeListeners(); for (int i = 0; i < listeners.length; i++) - listeners [i].stateChanged (changeEvent); + listeners[i].stateChanged(changeEvent); } } diff --git a/libjava/javax/swing/plaf/basic/BasicArrowButton.java b/libjava/javax/swing/plaf/basic/BasicArrowButton.java index b1245015703..8354d06a0ce 100644 --- a/libjava/javax/swing/plaf/basic/BasicArrowButton.java +++ b/libjava/javax/swing/plaf/basic/BasicArrowButton.java @@ -163,7 +163,7 @@ public class BasicArrowButton extends JButton implements SwingConstants /** The color the arrow is painted in if disabled and the bottom and * right edges of the button. */ - private transient Color shadow = Color.BLACK; + private transient Color shadow = Color.gray; /** The color the arrow is painted in if enabled and the bottom and * right edges of the button. */ @@ -350,30 +350,30 @@ public class BasicArrowButton extends JButton implements SwingConstants { Polygon arrow; double dsize = (double) size; - + + int one = (int) (dsize * 1 / 10); int two = (int) (dsize * 2 / 10); - int three = (int) (dsize * 3 / 10); - int five = (int) (dsize * 5 / 10); - int seven = (int) (dsize * 7 / 10); + int five = (int) (dsize * 5 / 10); int eight = (int) (dsize * 8 / 10); + switch (direction) { case NORTH: - arrow = new Polygon(new int[] { two, five, eight }, - new int[] { seven, three, seven }, 3); + arrow = new Polygon(new int[] { eight, five, one }, + new int[] { eight, one, eight }, 3); break; case SOUTH: - arrow = new Polygon(new int[] { two, five, eight }, - new int[] { three, seven, three }, 3); + arrow = new Polygon(new int[] { eight, five, two }, + new int[] { two, eight, two }, 3); break; case EAST: case RIGHT: - arrow = new Polygon(new int[] { three, seven, three }, + arrow = new Polygon(new int[] { two, eight, two }, new int[] { two, five, eight }, 3); break; case WEST: case LEFT: - arrow = new Polygon(new int[] { seven, three, seven }, + arrow = new Polygon(new int[] { eight, two, eight }, new int[] { two, five, eight }, 3); break; default: diff --git a/libjava/javax/swing/plaf/basic/BasicButtonListener.java b/libjava/javax/swing/plaf/basic/BasicButtonListener.java index 4dafc7e9f0b..2b4be67697c 100644 --- a/libjava/javax/swing/plaf/basic/BasicButtonListener.java +++ b/libjava/javax/swing/plaf/basic/BasicButtonListener.java @@ -37,6 +37,7 @@ exception statement from your version. */ package javax.swing.plaf.basic; +import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.InputEvent; @@ -46,6 +47,7 @@ import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.AbstractAction; import javax.swing.AbstractButton; import javax.swing.ButtonModel; import javax.swing.JComponent; @@ -64,8 +66,14 @@ public class BasicButtonListener } public void focusGained(FocusEvent e) { + if (e.getSource() instanceof AbstractButton) + { + AbstractButton button = (AbstractButton) e.getSource(); + if (button.isFocusPainted()) + button.repaint(); + } } - + public void focusLost(FocusEvent e) { if (e.getSource() instanceof AbstractButton) @@ -73,13 +81,43 @@ public class BasicButtonListener AbstractButton button = (AbstractButton) e.getSource(); ButtonModel model = button.getModel(); model.setArmed(false); + + if (button.isFocusPainted()) + button.repaint(); } } public void installKeyboardActions(JComponent c) { + c.getActionMap().put("pressed", + new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + AbstractButton button = (AbstractButton) e.getSource(); + ButtonModel model = button.getModel(); + // It is important that these transitions happen in this order. + model.setArmed(true); + model.setPressed(true); + } + }); + + c.getActionMap().put("released", + new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + AbstractButton button = (AbstractButton) e.getSource(); + ButtonModel model = button.getModel(); + // It is important that these transitions happen in this order. + model.setPressed(false); + model.setArmed(false); + } + }); } public void uninstallKeyboardActions(JComponent c) { + c.getActionMap().put("pressed", null); + c.getActionMap().put("released", null); } public void stateChanged(ChangeEvent e) { @@ -105,7 +143,7 @@ public class BasicButtonListener { AbstractButton button = (AbstractButton) e.getSource(); ButtonModel model = button.getModel(); - if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) + if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { // It is important that these transitions happen in this order. model.setArmed(true); @@ -128,7 +166,7 @@ public class BasicButtonListener { AbstractButton button = (AbstractButton) e.getSource(); ButtonModel model = button.getModel(); - if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) + if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { // It is important that these transitions happen in this order. model.setPressed(false); @@ -156,7 +194,7 @@ public class BasicButtonListener model.setRollover(true); if (model.isPressed() - && (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) + && (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) model.setArmed(true); else model.setArmed(false); diff --git a/libjava/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/javax/swing/plaf/basic/BasicButtonUI.java index 9134fb2e2e1..df7ac4269f0 100644 --- a/libjava/javax/swing/plaf/basic/BasicButtonUI.java +++ b/libjava/javax/swing/plaf/basic/BasicButtonUI.java @@ -50,6 +50,7 @@ import java.awt.Stroke; import javax.swing.AbstractButton; import javax.swing.ButtonModel; import javax.swing.Icon; +import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.SwingUtilities; import javax.swing.UIDefaults; @@ -59,13 +60,21 @@ import javax.swing.plaf.ComponentUI; public class BasicButtonUI extends ButtonUI { - /** A constant used to pad out elements in the button's layout and - preferred size calculations. */ - int defaultTextIconGap = 4; + /** + * A constant used to pad out elements in the button's layout and + * preferred size calculations. + */ + protected int defaultTextIconGap = 4; - /** A constant added to the defaultTextIconGap to adjust the text - within this particular button. */ - int defaultTextShiftOffset = 0; + /** + * A constant added to the defaultTextIconGap to adjust the text + * within this particular button. + */ + protected int defaultTextShiftOffset = 0; + + private int textShiftOffset; + + private Color focusColor; /** * Factory method to create an instance of BasicButtonUI for a given @@ -85,14 +94,32 @@ public class BasicButtonUI extends ButtonUI return defaultTextIconGap; } + protected void clearTextShiftOffset() + { + textShiftOffset = 0; + } + + protected int getTextShiftOffset() + { + return textShiftOffset; + } + + protected void setTextShiftOffset() + { + textShiftOffset = defaultTextShiftOffset; + } + protected void installDefaults(AbstractButton b) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + focusColor = defaults.getColor("Button.focus"); b.setForeground(defaults.getColor("Button.foreground")); b.setBackground(defaults.getColor("Button.background")); b.setMargin(defaults.getInsets("Button.margin")); b.setBorder(defaults.getBorder("Button.border")); b.setIconTextGap(defaults.getInt("Button.textIconGap")); + b.setInputMap(JComponent.WHEN_FOCUSED, + (InputMap) defaults.get("Button.focusInputMap")); b.setOpaque(true); } @@ -133,10 +160,12 @@ public class BasicButtonUI extends ButtonUI protected void installKeyboardActions(AbstractButton b) { + listener.installKeyboardActions(b); } protected void uninstallKeyboardActions(AbstractButton b) { + listener.uninstallKeyboardActions(b); } /** @@ -271,22 +300,12 @@ public class BasicButtonUI extends ButtonUI { if (b.hasFocus() && b.isFocusPainted()) { - Graphics2D g2 = (Graphics2D) g; - Stroke saved_stroke = g2.getStroke(); - Color saved_color = g2.getColor(); - float dashes[] = new float[] {1.0f, 1.0f}; - BasicStroke s = new BasicStroke(1.0f, - BasicStroke.CAP_SQUARE, - BasicStroke.JOIN_MITER, - 10, dashes, 0.0f); - g2.setStroke(s); - g2.setColor(Color.BLACK); - g2.drawRect(vr.x + 2, - vr.y + 2, - vr.width - 4, - vr.height - 4); - g2.setStroke(saved_stroke); - g2.setColor(saved_color); + Color saved_color = g.getColor(); + g.setColor(focusColor); + Rectangle focusRect = ir.union(tr); + g.drawRect(focusRect.x, focusRect.y, + focusRect.width, focusRect.height); + g.setColor(saved_color); } } diff --git a/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java index d394b951b7e..7101d427dd3 100644 --- a/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java +++ b/libjava/javax/swing/plaf/basic/BasicInternalFrameUI.java @@ -765,7 +765,7 @@ public class BasicInternalFrameUI extends InternalFrameUI lastComponentEntered); MouseEvent exited = new MouseEvent(lastComponentEntered, MouseEvent.MOUSE_EXITED, - me.getWhen(), me.getModifiers(), + me.getWhen(), me.getModifiersEx(), tp.x, tp.y, me.getClickCount(), me.isPopupTrigger(), me.getButton()); @@ -787,7 +787,7 @@ public class BasicInternalFrameUI extends InternalFrameUI MouseEvent entered = new MouseEvent(lastComponentEntered, MouseEvent.MOUSE_ENTERED, me.getWhen(), - me.getModifiers(), cp.x, + me.getModifiersEx(), cp.x, cp.y, me.getClickCount(), me.isPopupTrigger(), me.getButton()); diff --git a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java index 324fa01ff08..689cd8f57af 100644 --- a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -41,6 +41,7 @@ package javax.swing.plaf.basic; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.io.Serializable; import java.util.Enumeration; @@ -131,6 +132,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "SeparatorUI", "javax.swing.plaf.basic.BasicSeparatorUI", "SliderUI", "javax.swing.plaf.basic.BasicSliderUI", "SplitPaneUI", "javax.swing.plaf.basic.BasicSplitPaneUI", + "SpinnerUI", "javax.swing.plaf.basic.BasicSpinnerUI", "StandardDialogUI", "javax.swing.plaf.basic.BasicStandardDialogUI", "TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI", "TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI", @@ -246,6 +248,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "SPACE", "pressed", "released SPACE", "released" }), + "Button.focus", midPurple, "Button.font", new FontUIResource("Dialog", Font.PLAIN, 12), "Button.foreground", new ColorUIResource(Color.black), "Button.highlight", new ColorUIResource(Color.white), @@ -820,7 +823,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel "TextField.keyBindings", new JTextComponent.KeyBinding[] { new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), - "notify-field-accept")}, + "notify-field-accept"), + new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, + InputEvent.SHIFT_DOWN_MASK), + "selection-backward"), + new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, + InputEvent.SHIFT_DOWN_MASK), + "selection-forward"), + }, "TextField.margin", new InsetsUIResource(0, 0, 0, 0), "TextField.selectionBackground", new ColorUIResource(lightPurple), "TextField.selectionForeground", new ColorUIResource(Color.black), @@ -881,7 +891,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "ToolBar.font", new FontUIResource("Dialog", Font.PLAIN, 12), "ToolBar.foreground", new ColorUIResource(Color.black), "ToolBar.separatorSize", new DimensionUIResource(20, 20), - "ToolTip.background", new ColorUIResource(Color.white), + "ToolTip.background", new ColorUIResource(122, 178, 241), "ToolTip.border", new BorderUIResource.LineBorderUIResource(Color.lightGray), "ToolTip.font", new FontUIResource("SansSerif", Font.PLAIN, 12), "ToolTip.foreground", new ColorUIResource(Color.black), diff --git a/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java b/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java index f5b3e24c277..35fb005b9b9 100644 --- a/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java +++ b/libjava/javax/swing/plaf/basic/BasicPopupMenuUI.java @@ -163,6 +163,7 @@ public class BasicPopupMenuUI extends PopupMenuUI popupMenu.setBorder(defaults.getBorder("PopupMenu.border")); popupMenu.setFont(defaults.getFont("PopupMenu.font")); popupMenu.setForeground(defaults.getColor("PopupMenu.foreground")); + popupMenu.setOpaque(true); } /** @@ -228,11 +229,11 @@ public class BasicPopupMenuUI extends PopupMenuUI } /** - * This method returns the minimum size of the JPopupMenu. + * This method returns the minimum size of the JPopupMenu. * - * @param c The JComponent to find a size for. + * @param c The JComponent to find a size for. * - * @return The minimum size. + * @return The minimum size. */ public Dimension getMinimumSize(JComponent c) { @@ -264,13 +265,13 @@ public class BasicPopupMenuUI extends PopupMenuUI } /** - * Return true if given mouse event is a platform popup trigger, - * and false otherwise + * Return true if given mouse event is a platform popup trigger, and false + * otherwise * * @param e MouseEvent that is to be checked for popup trigger event * - * @return true if given mouse event is a platform popup trigger, - * and false otherwise + * @return true if given mouse event is a platform popup trigger, and false + * otherwise */ public boolean isPopupTrigger(MouseEvent e) { @@ -334,25 +335,25 @@ public class BasicPopupMenuUI extends PopupMenuUI path[0] = popupMenu; Component[] comps = popupMenu.getComponents(); if (comps.length != 0 && comps[0] instanceof MenuElement) - path[1] = (MenuElement) comps[0]; - manager.setSelectedPath(path); + { + path[1] = (MenuElement) comps[0]; + manager.setSelectedPath(path); + } } } } /** - * ComponentListener that listens to Component Events fired by the - * top - level window to which popup menu belongs. If top-level - * window was resized, moved or hidded then popup menu will - * be hidded and selected path of current menu hierarchy will be set - * to null. - * + * ComponentListener that listens to Component Events fired by the top - + * level window to which popup menu belongs. If top-level window was + * resized, moved or hidded then popup menu will be hidded and selected + * path of current menu hierarchy will be set to null. */ private class TopWindowListener implements ComponentListener { /** - * This method is invoked when top-level window is resized. - * This method closes current menu hierarchy. + * This method is invoked when top-level window is resized. This method + * closes current menu hierarchy. * * @param e The ComponentEvent */ @@ -363,8 +364,8 @@ public class BasicPopupMenuUI extends PopupMenuUI } /** - * This method is invoked when top-level window is moved. - * This method closes current menu hierarchy. + * This method is invoked when top-level window is moved. This method + * closes current menu hierarchy. * * @param e The ComponentEvent */ @@ -375,8 +376,8 @@ public class BasicPopupMenuUI extends PopupMenuUI } /** - * This method is invoked when top-level window is shown - * This method does nothing by default. + * This method is invoked when top-level window is shown This method does + * nothing by default. * * @param e The ComponentEvent */ @@ -387,8 +388,8 @@ public class BasicPopupMenuUI extends PopupMenuUI } /** - * This method is invoked when top-level window is hidden - * This method closes current menu hierarchy. + * This method is invoked when top-level window is hidden This method + * closes current menu hierarchy. * * @param e The ComponentEvent */ diff --git a/libjava/javax/swing/plaf/basic/BasicSliderUI.java b/libjava/javax/swing/plaf/basic/BasicSliderUI.java index 7334b2e0eb3..b5c95cb68c3 100644 --- a/libjava/javax/swing/plaf/basic/BasicSliderUI.java +++ b/libjava/javax/swing/plaf/basic/BasicSliderUI.java @@ -1226,6 +1226,7 @@ public class BasicSliderUI extends SliderUI if (slider.getLabelTable() == null) return 0; + Dimension pref; for (Enumeration list = slider.getLabelTable().elements(); list.hasMoreElements();) { @@ -1233,8 +1234,9 @@ public class BasicSliderUI extends SliderUI if (! (comp instanceof Component)) continue; label = (Component) comp; - if (label.getWidth() > widest) - widest = label.getWidth(); + pref = label.getPreferredSize(); + if (pref != null && pref.width > widest) + widest = pref.width; } return widest; } @@ -1252,7 +1254,7 @@ public class BasicSliderUI extends SliderUI if (slider.getLabelTable() == null) return 0; - + Dimension pref; for (Enumeration list = slider.getLabelTable().elements(); list.hasMoreElements();) { @@ -1260,8 +1262,9 @@ public class BasicSliderUI extends SliderUI if (! (comp instanceof Component)) continue; label = (Component) comp; - if (label.getHeight() > tallest) - tallest = label.getHeight(); + pref = label.getPreferredSize(); + if (pref != null && pref.height > tallest) + tallest = pref.height; } return tallest; } diff --git a/libjava/javax/swing/plaf/basic/BasicTextUI.java b/libjava/javax/swing/plaf/basic/BasicTextUI.java index 817a5e4a290..2ccf2fa5e08 100644 --- a/libjava/javax/swing/plaf/basic/BasicTextUI.java +++ b/libjava/javax/swing/plaf/basic/BasicTextUI.java @@ -46,8 +46,16 @@ import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Shape; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.Action; +import javax.swing.ActionMap; +import javax.swing.InputMap; import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import javax.swing.UIDefaults; +import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.TextUI; import javax.swing.plaf.UIResource; @@ -61,7 +69,9 @@ import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; +import javax.swing.text.Keymap; import javax.swing.text.PlainDocument; +import javax.swing.text.PlainView; import javax.swing.text.Position; import javax.swing.text.View; import javax.swing.text.ViewFactory; @@ -88,14 +98,18 @@ public abstract class BasicTextUI extends TextUI private class RootView extends View { - private JTextComponent textComponent; private View view; - public RootView(JTextComponent parent) - { - super(null); - textComponent = parent; - } + public RootView() + { + super(null); + } + + public ViewFactory getViewFactory() + { + // FIXME: Handle EditorKit somehow. + return BasicTextUI.this; + } public void setView(View v) { @@ -123,17 +137,34 @@ public abstract class BasicTextUI extends TextUI public void paint(Graphics g, Shape s) { - System.out.println("Michael: BasicTextUI.RootView.paint"); - if (view != null) view.paint(g, s); - } + } + + protected Rectangle modelToView(int position, Shape a, Position.Bias bias) + throws BadLocationException + { + return ((PlainView) view).modelToView(position, a, bias).getBounds(); + } + } + + class UpdateHandler implements PropertyChangeListener + { + public void propertyChange(PropertyChangeEvent event) + { + if (event.getPropertyName().equals("document")) + { + // Document changed. + modelChanged(); + } + } } - RootView rootView; + static EditorKit kit = new DefaultEditorKit(); + + RootView rootView = new RootView(); JTextComponent textComponent; - int gap = 3; - EditorKit kit = new DefaultEditorKit(); + UpdateHandler updateHandler = new UpdateHandler(); public BasicTextUI() { @@ -164,12 +195,12 @@ public abstract class BasicTextUI extends TextUI Document doc = textComponent.getDocument(); if (doc == null) { - doc = new PlainDocument(); + doc = getEditorKit(textComponent).createDefaultDocument(); textComponent.setDocument(doc); - } - - rootView = new RootView(textComponent); - setView(create(doc.getDefaultRootElement())); + } + + textComponent.addPropertyChangeListener(updateHandler); + modelChanged(); installDefaults(); installListeners(); @@ -178,20 +209,115 @@ public abstract class BasicTextUI extends TextUI protected void installDefaults() { + Caret caret = textComponent.getCaret(); + if (caret == null) + { + caret = createCaret(); + textComponent.setCaret(caret); + } + + Highlighter highlighter = textComponent.getHighlighter(); + if (highlighter == null) + textComponent.setHighlighter(createHighlighter()); + + String prefix = getPropertyPrefix(); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + textComponent.setBackground(defaults.getColor(prefix + ".background")); + textComponent.setForeground(defaults.getColor(prefix + ".foreground")); + textComponent.setMargin(defaults.getInsets(prefix + ".margin")); + textComponent.setBorder(defaults.getBorder(prefix + ".border")); + textComponent.setFont(defaults.getFont(prefix + ".font")); + + caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate")); } protected void installListeners() { + // Do nothing here. + } + + protected String getKeymapName() + { + return "BasicTextUI"; + } + + protected Keymap createKeymap() + { + String prefix = getPropertyPrefix(); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + JTextComponent.KeyBinding[] bindings = + (JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings"); + Keymap km = JTextComponent.addKeymap(getKeymapName(), + JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP)); + JTextComponent.loadKeymap(km, bindings, textComponent.getActions()); + return km; } protected void installKeyboardActions() + { + // load any bindings for the older Keymap interface + Keymap km = JTextComponent.getKeymap(getKeymapName()); + if (km == null) + km = createKeymap(); + textComponent.setKeymap(km); + + // load any bindings for the newer InputMap / ActionMap interface + SwingUtilities.replaceUIInputMap(textComponent, + JComponent.WHEN_FOCUSED, + getInputMap(JComponent.WHEN_FOCUSED)); + SwingUtilities.replaceUIActionMap(textComponent, getActionMap()); + } + + InputMap getInputMap(int condition) + { + String prefix = getPropertyPrefix(); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + switch (condition) + { + case JComponent.WHEN_IN_FOCUSED_WINDOW: + // FIXME: is this the right string? nobody seems to use it. + return (InputMap) defaults.get(prefix + ".windowInputMap"); + case JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT: + return (InputMap) defaults.get(prefix + ".ancestorInputMap"); + default: + case JComponent.WHEN_FOCUSED: + return (InputMap) defaults.get(prefix + ".focusInputMap"); + } + } + + ActionMap getActionMap() + { + String prefix = getPropertyPrefix(); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + ActionMap am = (ActionMap) defaults.get(prefix + ".actionMap"); + if (am == null) + { + am = createActionMap(); + defaults.put(prefix + ".actionMap", am); + } + return am; + } + + ActionMap createActionMap() { + Action[] actions = textComponent.getActions(); + ActionMap am = new ActionMap(); + for (int i = 0; i < actions.length; ++i) + { + String name = (String) actions[i].getValue(Action.NAME); + if (name != null) + am.put(name, actions[i]); + } + return am; } - public void uninstallUI(final JComponent c) + public void uninstallUI(final JComponent component) { - super.uninstallUI(c); - rootView = null; + super.uninstallUI(component); + rootView.setView(null); + + textComponent.removePropertyChangeListener(updateHandler); + textComponent = null; uninstallDefaults(); uninstallListeners(); @@ -200,14 +326,17 @@ public abstract class BasicTextUI extends TextUI protected void uninstallDefaults() { + // Do nothing here. } protected void uninstallListeners() { + // Do nothing here. } protected void uninstallKeyboardActions() { + // Do nothing here. } protected abstract String getPropertyPrefix(); @@ -235,18 +364,19 @@ public abstract class BasicTextUI extends TextUI if (textComponent.isOpaque()) paintBackground(g); - rootView.paint(g, getVisibleEditorRect()); - - if (highlighter != null) + if (highlighter != null + && textComponent.getSelectionStart() != textComponent.getSelectionEnd()) highlighter.paint(g); + rootView.paint(g, getVisibleEditorRect()); + if (caret != null) caret.paint(g); } protected void paintBackground(Graphics g) { - g.setColor(Color.WHITE); // FIXME: set background color + g.setColor(textComponent.getBackground()); g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight()); } @@ -281,13 +411,13 @@ public abstract class BasicTextUI extends TextUI public Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException { - return modelToView(t, pos, null); + return modelToView(t, pos, Position.Bias.Forward); } public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException { - return null; + return rootView.modelToView(pos, getVisibleEditorRect(), bias).getBounds(); } public int viewToModel(JTextComponent t, Point pt) @@ -331,4 +461,11 @@ public abstract class BasicTextUI extends TextUI rootView.setView(view); view.setParent(rootView); } + + protected void modelChanged() + { + ViewFactory factory = rootView.getViewFactory(); + Element elem = textComponent.getDocument().getDefaultRootElement(); + setView(factory.create(elem)); + } } diff --git a/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java b/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java index a319b0b4e02..1dc6423ee76 100644 --- a/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java +++ b/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java @@ -43,12 +43,10 @@ import javax.swing.plaf.ComponentUI; public class BasicToggleButtonUI extends BasicButtonUI { - - public static ComponentUI createUI(final JComponent c) { - return new BasicToggleButtonUI(); - } -} - - + public static ComponentUI createUI(final JComponent component) + { + return new BasicToggleButtonUI(); + } +} diff --git a/libjava/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/javax/swing/plaf/basic/BasicToolBarUI.java index 4fb142b1c9e..99e447501a5 100644 --- a/libjava/javax/swing/plaf/basic/BasicToolBarUI.java +++ b/libjava/javax/swing/plaf/basic/BasicToolBarUI.java @@ -157,13 +157,11 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants /** * This method creates a new BasicToolBarUI object for the given JToolBar. - * - * @param b The JToolBar to represent with this UI. */ - public BasicToolBarUI(JToolBar b) - { - super(); - } + public BasicToolBarUI() + { + super(); + } /** * This method returns whether the JToolBar can dock at the given position. @@ -351,10 +349,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants * * @return A new UI delegate. */ - public static ComponentUI createUI(JComponent c) - { - return new BasicToolBarUI((JToolBar) c); - } + public static ComponentUI createUI(JComponent c) + { + return new BasicToolBarUI(); + } /** * This method is called to drag the DragWindow around when the JToolBar is diff --git a/libjava/javax/swing/table/DefaultTableCellRenderer.java b/libjava/javax/swing/table/DefaultTableCellRenderer.java index 563d9e60af2..ef829886147 100644 --- a/libjava/javax/swing/table/DefaultTableCellRenderer.java +++ b/libjava/javax/swing/table/DefaultTableCellRenderer.java @@ -122,8 +122,22 @@ public class DefaultTableCellRenderer extends JLabel { if (value!=null) super.setText(value.toString()); - - return this; + + setOpaque(true); + if (isSelected) + { + setBackground(table.getSelectionBackground()); + setForeground(table.getSelectionForeground()); + } + else + { + setBackground(table.getBackground()); + setForeground(table.getForeground()); + } + + setEnabled(table.isEnabled()); + setFont(table.getFont()); + return this; } /** @@ -150,6 +164,11 @@ public class DefaultTableCellRenderer extends JLabel // Does nothing. } + public void revalidate() + { + // Does nothing. + } + /** * Overriden for performance. * diff --git a/libjava/javax/swing/table/DefaultTableColumnModel.java b/libjava/javax/swing/table/DefaultTableColumnModel.java index ea46ce5672b..d7a3c351938 100644 --- a/libjava/javax/swing/table/DefaultTableColumnModel.java +++ b/libjava/javax/swing/table/DefaultTableColumnModel.java @@ -1,5 +1,5 @@ /* DefaultTableColumnModel.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -44,6 +44,7 @@ import java.util.Enumeration; import java.util.EventListener; import java.util.Vector; import javax.swing.ListSelectionModel; +import javax.swing.DefaultListSelectionModel; import javax.swing.event.ChangeEvent; import javax.swing.event.EventListenerList; import javax.swing.event.ListSelectionEvent; @@ -61,86 +62,93 @@ public class DefaultTableColumnModel implements TableColumnModel, PropertyChangeListener, ListSelectionListener, Serializable { - static final long serialVersionUID = 6580012493508960512L; - - /** - * tableColumns - */ - protected Vector tableColumns; - - /** - * selectionModel - */ - protected ListSelectionModel selectionModel; - - /** - * columnMargin - */ - protected int columnMargin; - - /** - * listenerList - */ - protected EventListenerList listenerList; - - /** - * changeEvent - */ - protected transient ChangeEvent changeEvent; - - /** - * columnSelectionAllowed - */ - protected boolean columnSelectionAllowed; - - /** - * totalColumnWidth - */ - protected int totalColumnWidth; - - /** - * Constructor DefaultTableColumnModel - */ + private static final long serialVersionUID = 6580012493508960512L; + + /** + * tableColumns + */ + protected Vector tableColumns; + + /** + * selectionModel + */ + protected ListSelectionModel selectionModel; + + /** + * columnMargin + */ + protected int columnMargin; + + /** + * listenerList + */ + protected EventListenerList listenerList = new EventListenerList(); + + /** + * changeEvent + */ + protected transient ChangeEvent changeEvent = new ChangeEvent(this); + + /** + * columnSelectionAllowed + */ + protected boolean columnSelectionAllowed; + + /** + * totalColumnWidth + */ + protected int totalColumnWidth; + + /** + * Constructor DefaultTableColumnModel + */ public DefaultTableColumnModel() { - // TODO + tableColumns = new Vector(); + setSelectionModel(new DefaultListSelectionModel()); + columnMargin = 1; + columnSelectionAllowed = false; } - /** - * addColumn - * @param value0 TODO - */ - public void addColumn(TableColumn value0) + /** + * addColumn + * @param value0 TODO + */ + public void addColumn(TableColumn col) { - // TODO + tableColumns.add(col); + invalidateWidthCache(); } - /** - * removeColumn - * @param value0 TODO - */ - public void removeColumn(TableColumn value0) + /** + * removeColumn + * @param value0 TODO + */ + public void removeColumn(TableColumn col) { - // TODO + tableColumns.remove(col); + invalidateWidthCache(); } - /** - * moveColumn - * @param value0 TODO - * @param value1 TODO - */ - public void moveColumn(int value0, int value1) + /** + * moveColumn + * @param value0 TODO + * @param value1 TODO + */ + public void moveColumn(int i, int j) { - // TODO + Object tmp = tableColumns.get(i); + tableColumns.set(i, tableColumns.get(j)); + tableColumns.set(j, tmp); } - /** - * setColumnMargin - * @param value0 TODO - */ - public void setColumnMargin(int value0) + /** + * setColumnMargin + * @param value0 TODO + */ + public void setColumnMargin(int m) { - // TODO + columnMargin = m; } /** @@ -149,7 +157,7 @@ public class DefaultTableColumnModel */ public int getColumnCount() { - return 0; // TODO + return tableColumns.size(); } /** @@ -158,27 +166,27 @@ public class DefaultTableColumnModel */ public Enumeration getColumns() { - return null; // TODO + return tableColumns.elements(); } /** * getColumnIndex * @param value0 TODO * @return int - */ - public int getColumnIndex(Object value0) + */ + public int getColumnIndex(Object obj) { - return 0; // TODO + return tableColumns.indexOf(obj, 0); } /** * getColumn * @param value0 TODO * @return TableColumn - */ - public TableColumn getColumn(int value0) + */ + public TableColumn getColumn(int i) { - return null; // TODO + return (TableColumn) tableColumns.get(i); } /** @@ -187,17 +195,25 @@ public class DefaultTableColumnModel */ public int getColumnMargin() { - return 0; // TODO + return columnMargin; } /** * getColumnIndexAtX * @param value0 TODO * @return int - */ - public int getColumnIndexAtX(int value0) - { - return 0; // TODO + */ + public int getColumnIndexAtX(int x) + { + for (int i = 0; i < tableColumns.size(); ++i) + { + int w = ((TableColumn)tableColumns.get(i)).getWidth(); + if (0 <= x && x < w) + return i; + else + x -= w; + } + return -1; } /** @@ -206,16 +222,23 @@ public class DefaultTableColumnModel */ public int getTotalColumnWidth() { - return 0; // TODO + if (totalColumnWidth == -1) + recalcWidthCache(); + return totalColumnWidth; } - /** - * setSelectionModel - * @param value0 TODO - */ - public void setSelectionModel(ListSelectionModel value0) + /** + * setSelectionModel + * @param model TODO + * @exception IllegalArgumentException if model is null + */ + public void setSelectionModel(ListSelectionModel model) { - // TODO + if (model == null) + throw new IllegalArgumentException(); + + selectionModel = model; + selectionModel.addListSelectionListener(this); } /** @@ -224,16 +247,16 @@ public class DefaultTableColumnModel */ public ListSelectionModel getSelectionModel() { - return null; // TODO + return selectionModel; } - /** - * setColumnSelectionAllowed - * @param value0 TODO - */ - public void setColumnSelectionAllowed(boolean value0) + /** + * setColumnSelectionAllowed + * @param value0 TODO + */ + public void setColumnSelectionAllowed(boolean a) { - // TODO + columnSelectionAllowed = a; } /** @@ -242,7 +265,7 @@ public class DefaultTableColumnModel */ public boolean getColumnSelectionAllowed() { - return false; // TODO + return columnSelectionAllowed; } /** @@ -263,13 +286,13 @@ public class DefaultTableColumnModel return 0; // TODO } - /** - * addColumnModelListener - * @param value0 TODO - */ - public void addColumnModelListener(TableColumnModelListener value0) + /** + * addColumnModelListener + * @param value0 TODO + */ + public void addColumnModelListener(TableColumnModelListener listener) { - // TODO + listenerList.add(TableColumnModelListener.class, listener); } /** @@ -308,13 +331,15 @@ public class DefaultTableColumnModel // TODO } - /** - * fireColumnSelectionChanged - * @param value0 TODO - */ - protected void fireColumnSelectionChanged(ListSelectionEvent value0) + /** + * fireColumnSelectionChanged + * @param value0 TODO + */ + protected void fireColumnSelectionChanged(ListSelectionEvent evt) { - // TODO + EventListener [] listeners = getListeners(TableColumnModelListener.class); + for (int i = 0; i < listeners.length; ++i) + ((TableColumnModelListener)listeners[i]).columnSelectionChanged(evt); } /** @@ -329,10 +354,10 @@ public class DefaultTableColumnModel * getListeners * @param value0 TODO * @return EventListener[] - */ - public EventListener[] getListeners(Class value0) + */ + public EventListener[] getListeners(Class klass) { - return null; // TODO + return listenerList.getListeners(klass); } /** @@ -350,7 +375,7 @@ public class DefaultTableColumnModel */ public void valueChanged(ListSelectionEvent value0) { - // TODO + fireColumnSelectionChanged(value0); } /** @@ -367,7 +392,14 @@ public class DefaultTableColumnModel */ protected void recalcWidthCache() { - // TODO + if (totalColumnWidth == -1) + { + totalColumnWidth = 0; + for (int i = 0; i < tableColumns.size(); ++i) + { + totalColumnWidth += ((TableColumn)tableColumns.get(i)).getWidth(); + } + } } /** @@ -375,6 +407,6 @@ public class DefaultTableColumnModel */ private void invalidateWidthCache() { - // TODO + totalColumnWidth = -1; } } diff --git a/libjava/javax/swing/table/DefaultTableModel.java b/libjava/javax/swing/table/DefaultTableModel.java index 5c57f81c639..8e111303c34 100644 --- a/libjava/javax/swing/table/DefaultTableModel.java +++ b/libjava/javax/swing/table/DefaultTableModel.java @@ -50,445 +50,387 @@ public class DefaultTableModel extends AbstractTableModel implements Serializable { static final long serialVersionUID = 6680042567037222321L; - - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * dataVector - */ - protected Vector dataVector; - - /** - * columnIdentifiers - */ - protected Vector columnIdentifiers; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor DefaultTableModel - */ - public DefaultTableModel() { - this(0, 0); - } // DefaultTableModel() - - /** - * Constructor DefaultTableModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTableModel(int numRows, int numColumns) { - - // Variables - int columnIndex; - Vector defaultNames; - - // Create Column Names - defaultNames = new Vector(); - for (columnIndex = 0; columnIndex < numColumns; columnIndex++) { - defaultNames.addElement(super.getColumnName(columnIndex)); - } // for - - // Setup Data -// setDataVector(defaultNames, numRows); - - } // DefaultTableModel() - - /** - * Constructor DefaultTableModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTableModel(Vector columnNames, int numRows) { - - // Variables - Vector data; - Vector rowData; - int rowIndex; - int numColumns; - - // Create Data - data = new Vector(); - if (columnNames == null) { - numColumns = 0; - } else { - numColumns = columnNames.size(); - } // if - for (rowIndex = 0; rowIndex < numRows; rowIndex++) { - rowData = new Vector(); - rowData.setSize(numColumns); - data.addElement(rowData); - } // for - - // Setup Data - setDataVector(data, columnNames); - - } // DefaultTableModel() - - /** - * Constructor DefaultTableModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTableModel(Object[] columnNames, int numRows) { - this(convertToVector(columnNames), numRows); - } // DefaultTableModel() - - /** - * Constructor DefaultTableModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTableModel(Vector data, Vector columnNames) { - setDataVector(data, columnNames); - } // DefaultTableModel() - - /** - * Constructor DefaultTableModel - * @param value0 TODO - * @param value1 TODO - */ - public DefaultTableModel(Object[][] data, Object[] columnNames) { - this(convertToVector(data), convertToVector(columnNames)); - } // DefaultTableModel() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getDataVector - * @returns Vector - */ - public Vector getDataVector() { - return dataVector; - } // getDataVector() - - /** - * setDataVector - * @param value0 TODO - * @param value1 TODO - */ - public void setDataVector(Vector data, Vector columnNames) { - - // Variables - int rowIndex; - int numRows; - int numColumns; - Vector columnVector; - - // Set Data - dataVector = data; - columnIdentifiers = columnNames; - - // Check Data - numRows = data.size(); - numColumns = columnNames.size(); - for (rowIndex = 0; rowIndex < numRows; rowIndex++) { - columnVector = (Vector) dataVector.get(rowIndex); - columnVector.setSize(numColumns); - } // for - - } // setDataVector() - - /** - * setDataVector - * @param value0 TODO - * @param value1 TODO - */ - public void setDataVector(Object[][] data, Object[] columnNames) { - setDataVector(convertToVector(data), convertToVector(columnNames)); - } // setDataVector() - - /** - * newDataAvailable - * @param value0 TODO - */ - public void newDataAvailable(TableModelEvent event) { - fireTableChanged(event); - } // newDataAvailable() - - /** - * newRowsAdded - * @param value0 TODO - */ - public void newRowsAdded(TableModelEvent event) { - // TODO - } // newRowsAdded() - - /** - * rowsRemoved - * @param value0 TODO - */ - public void rowsRemoved(TableModelEvent event) { - fireTableChanged(event); - } // rowsRemoved() - - /** - * setColumnIdentifiers - * @param value0 TODO - */ - public void setColumnIdentifiers(Vector columnIdentifiers) { - this.columnIdentifiers = columnIdentifiers; - setColumnCount(columnIdentifiers.size()); - } // setColumnIdentifiers() - - /** - * setColumnIdentifiers - * @param value0 TODO - */ - public void setColumnIdentifiers(Object[] columnIdentifiers) { - setColumnIdentifiers(convertToVector(columnIdentifiers)); - } // setColumnIdentifiers() - - /** - * setNumRows - * @param value0 TODO - */ - public void setNumRows(int numRows) { - setRowCount(numRows); - } // setNumRows() - - /** - * setRowCount - * @param value0 TODO - */ - public void setRowCount(int rowCount) { - // TODO - } // setRowCount() - - /** - * setColumnCount - * @param value0 TODO - */ - public void setColumnCount(int columnCount) { - // TODO - } // setColumnCount() - - /** - * addColumn - * @param value0 TODO - */ - public void addColumn(Object columnName) { - addColumn(columnName, new Vector(dataVector.size())); - } // addColumn() - - /** - * addColumn - * @param value0 TODO - * @param value1 TODO - */ - public void addColumn(Object columnName, Vector columnData) { - // TODO - } // addColumn() - - /** - * addColumn - * @param value0 TODO - * @param value1 TODO - */ - public void addColumn(Object columnName, Object[] columnData) { - // TODO - } // addColumn() - - /** - * addRow - * @param value0 TODO - */ - public void addRow(Vector rowData) { - // TODO - } // addRow() - - /** - * addRow - * @param value0 TODO - */ - public void addRow(Object[] rowData) { - addRow(convertToVector(rowData)); - } // addRow() - - /** - * insertRow - * @param value0 TODO - * @param value1 TODO - */ - public void insertRow(int row, Vector rowData) { - dataVector.add(row, rowData); - } // insertRow() - - /** - * insertRow - * @param value0 TODO - * @param value1 TODO - */ - public void insertRow(int row, Object[] rowData) { - insertRow(row, convertToVector(rowData)); - } // insertRow() - - /** - * moveRow - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - */ - public void moveRow(int startIndex, int endIndex, int toIndex) { - - // Variables - int index; - Vector vector; - - // Move Rows - for (index = 0; index < (endIndex - startIndex); index++) { - vector = (Vector) dataVector.remove(startIndex); - dataVector.add(toIndex, vector); - } // for - - } // moveRow() - - /** - * removeRow - * @param value0 TODO - */ - public void removeRow(int row) { - dataVector.remove(row); - } // removeRow() - - /** - * getRowCount - * @returns int - */ - public int getRowCount() { - return dataVector.size(); - } // getRowCount() - - /** - * getColumnCount - * @returns int - */ - public int getColumnCount() { - return columnIdentifiers.size(); - } // getColumnCount() - - /** - * getColumnName - * @param value0 TODO - * @returns String - */ - public String getColumnName(int column) { - - // Check for Column - if (columnIdentifiers == null || column >= getColumnCount()) { - return super.getColumnName(column); - } // if - - // Return Column name - return (String) columnIdentifiers.get(column); - - } // getColumnName() - - /** - * isCellEditable - * @param value0 TODO - * @param value1 TODO - * @returns boolean - */ - public boolean isCellEditable(int row, int column) { - return true; - } // isCellEditable() - - /** - * getValueAt - * @param value0 TODO - * @param value1 TODO - * @returns Object - */ - public Object getValueAt(int row, int column) { - - // Variables - Vector rowVector; - - // Get Row Vector - rowVector = (Vector) dataVector.get(row); - - // Get Data - return rowVector.get(column); - - } // getValueAt() - - /** - * setValueAt - * @param value0 TODO - * @param value1 TODO - * @param value2 TODO - */ - public void setValueAt(Object value, int row, int column) { - - // Variables - Vector rowVector; - - // Get Row Vector - rowVector = (Vector) dataVector.get(row); - - // Set Data - rowVector.remove(column); - rowVector.add(column, value); - - } // setValueAt() - - /** - * convertToVector - * @param value0 TODO - * @returns Vector - */ - protected static Vector convertToVector(Object[] data) { - - // Variables - int index; - Vector vector; - - // Check for null - if (data == null) { - return null; - } // if - - // Process - vector = new Vector(); - for (index = 0; index < data.length; index++) { - vector.add(data[index]); - } // for: index - - // Return new Vector - return vector; - - } // convertToVector() - - /** - * convertToVector - * @param value0 TODO - * @returns Vector - */ - protected static Vector convertToVector(Object[][] data) { - - // Variables - int index; - Vector vector; - - // Process - vector = new Vector(); - for (index = 0; index < data.length; index++) { - vector.add(convertToVector(data[index])); - } // for: index - - // Return new Vector - return vector; - - } // convertToVector() - - -} // DefaultTableModel + /** + * dataVector + */ + protected Vector dataVector; + + /** + * columnIdentifiers + */ + protected Vector columnIdentifiers; + + /** + * Constructor DefaultTableModel + */ + public DefaultTableModel() + { + this(0, 0); + } + + /** + * Constructor DefaultTableModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTableModel(int numRows, int numColumns) + { + Vector defaultNames = new Vector(numColumns); + Vector data = new Vector(numRows); + for (int i = 0; i < numColumns; i++) + { + defaultNames.add(super.getColumnName(i)); + Vector tmp = new Vector(numColumns); + tmp.setSize(numColumns); + data.add(tmp); + } + setDataVector(defaultNames, data); + } + + /** + * Constructor DefaultTableModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTableModel(Vector columnNames, int numRows) + { + Vector data = new Vector(); + int numColumns = 0; + + if (columnNames != null) + numColumns = columnNames.size(); + + while (0 < numRows--) + { + Vector rowData = new Vector(); + rowData.setSize(numColumns); + data.add(rowData); + } + setDataVector(data, columnNames); + } + + /** + * Constructor DefaultTableModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTableModel(Object[] columnNames, int numRows) + { + this(convertToVector(columnNames), numRows); + } + + /** + * Constructor DefaultTableModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTableModel(Vector data, Vector columnNames) + { + setDataVector(data, columnNames); + } + + /** + * Constructor DefaultTableModel + * @param value0 TODO + * @param value1 TODO + */ + public DefaultTableModel(Object[][] data, Object[] columnNames) + { + this(convertToVector(data), convertToVector(columnNames)); + } + + /** + * getDataVector + * @returns Vector + */ + public Vector getDataVector() + { + return dataVector; + } + + /** + * setDataVector + * @param value0 TODO + * @param value1 TODO + */ + public void setDataVector(Vector data, Vector columnNames) + { + dataVector = data; + columnIdentifiers = columnNames; + for (int r = 0; r < data.size(); r++) { + ((Vector) dataVector.get(r)).setSize(columnNames.size()); + } + } + + /** + * setDataVector + * @param value0 TODO + * @param value1 TODO + */ + public void setDataVector(Object[][] data, Object[] columnNames) + { + setDataVector(convertToVector(data), + convertToVector(columnNames)); + } + + /** + * newDataAvailable + * @param value0 TODO + */ + public void newDataAvailable(TableModelEvent event) + { + fireTableChanged(event); + } + + /** + * newRowsAdded + * @param value0 TODO + */ + public void newRowsAdded(TableModelEvent event) + { + fireTableChanged(event); + } + + /** + * rowsRemoved + * @param value0 TODO + */ + public void rowsRemoved(TableModelEvent event) + { + fireTableChanged(event); + } + + /** + * setColumnIdentifiers + * @param value0 TODO + */ + public void setColumnIdentifiers(Vector columnIdentifiers) + { + this.columnIdentifiers = columnIdentifiers; + setColumnCount(columnIdentifiers.size()); + } + + /** + * setColumnIdentifiers + * @param value0 TODO + */ + public void setColumnIdentifiers(Object[] columnIdentifiers) + { + setColumnIdentifiers(convertToVector(columnIdentifiers)); + } + + /** + * setNumRows + * @param value0 TODO + */ + public void setNumRows(int numRows) + { + setRowCount(numRows); + } + + /** + * setRowCount + * @param value0 TODO + */ + public void setRowCount(int rowCount) + { + dataVector.setSize(rowCount); + fireTableDataChanged(); + } + + /** + * setColumnCount + * @param value0 TODO + */ + public void setColumnCount(int columnCount) + { + for (int i = 0; i < dataVector.size(); ++i) + { + ((Vector) dataVector.get(i)).setSize(columnCount); + } + columnIdentifiers.setSize(columnCount); + fireTableDataChanged(); + } + + /** + * addColumn + * @param value0 TODO + */ + public void addColumn(Object columnName) + { + addColumn(columnName, (Object[]) null); + } + + /** + * addColumn + * @param value0 TODO + * @param value1 TODO + */ + public void addColumn(Object columnName, Vector columnData) + { + addColumn(columnName, columnData == null ? null : columnData.toArray()); + } + + /** + * addColumn + * @param value0 TODO + * @param value1 TODO + */ + public void addColumn(Object columnName, Object[] columnData) { + for (int i = 0; i < dataVector.size(); ++i) + { + ((Vector) dataVector.get(i)).add(columnData == null ? null : columnData[i]); + } + columnIdentifiers.add(columnName); + fireTableDataChanged(); + } + + /** + * addRow + * @param value0 TODO + */ + public void addRow(Vector rowData) { + dataVector.add(rowData); + fireTableDataChanged(); + } + + /** + * addRow + * @param value0 TODO + */ + public void addRow(Object[] rowData) { + addRow(convertToVector(rowData)); + } + + /** + * insertRow + * @param value0 TODO + * @param value1 TODO + */ + public void insertRow(int row, Vector rowData) { + dataVector.add(row, rowData); + fireTableDataChanged(); + } + + /** + * insertRow + * @param value0 TODO + * @param value1 TODO + */ + public void insertRow(int row, Object[] rowData) { + insertRow(row, convertToVector(rowData)); + } + + /** + * moveRow + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + */ + public void moveRow(int startIndex, int endIndex, int toIndex) { + for (int index = 0; index < (endIndex - startIndex); index++) { + Vector vector = (Vector) dataVector.remove(startIndex); + dataVector.add(toIndex, vector); + } + fireTableDataChanged(); + } + + /** + * removeRow + * @param value0 TODO + */ + public void removeRow(int row) { + dataVector.remove(row); + fireTableDataChanged(); + } + + /** + * getRowCount + * @returns int + */ + public int getRowCount() { + return dataVector.size(); + } + + /** + * getColumnCount + * @returns int + */ + public int getColumnCount() { + return columnIdentifiers.size(); + } + + /** + * getColumnName + * @param value0 TODO + * @returns String + */ + public String getColumnName(int column) { + // Check for Column + if (columnIdentifiers == null || column >= getColumnCount()) { + return super.getColumnName(column); + } + + // Return Column name + return (String) columnIdentifiers.get(column); + } + + /** + * isCellEditable + * @param value0 TODO + * @param value1 TODO + * @returns boolean + */ + public boolean isCellEditable(int row, int column) { + return true; + } + + /** + * getValueAt + * @param value0 TODO + * @param value1 TODO + * @returns Object + */ + public Object getValueAt(int row, int column) { + return ((Vector) dataVector.get(row)).get(column); + } + + /** + * setValueAt + * @param value0 TODO + * @param value1 TODO + * @param value2 TODO + */ + public void setValueAt(Object value, int row, int column) { + ((Vector) dataVector.get(row)).set(column, value); + fireTableDataChanged(); + } + + /** + * convertToVector + * @param value0 TODO + * @returns Vector + */ + protected static Vector convertToVector(Object[] data) { + if (data == null) + return null; + Vector vector = new Vector(data.length); + for (int i = 0; i < data.length; i++) + vector.add(data[i]); + return vector; + } + + /** + * convertToVector + * @param value0 TODO + * @returns Vector + */ + protected static Vector convertToVector(Object[][] data) { + if (data == null) + return null; + Vector vector = new Vector(data.length); + for (int i = 0; i < data.length; i++) + vector.add(convertToVector(data[i])); + return vector; + } +} diff --git a/libjava/javax/swing/table/JTableHeader.java b/libjava/javax/swing/table/JTableHeader.java index 6b486019532..9e55647f42f 100644 --- a/libjava/javax/swing/table/JTableHeader.java +++ b/libjava/javax/swing/table/JTableHeader.java @@ -38,26 +38,536 @@ exception statement from your version. */ package javax.swing.table; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Point; +import java.awt.Rectangle; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Locale; + +import javax.accessibility.Accessible; +import javax.accessibility.AccessibleAction; +import javax.accessibility.AccessibleComponent; +import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleSelection; +import javax.accessibility.AccessibleStateSet; +import javax.accessibility.AccessibleRole; +import javax.accessibility.AccessibleText; +import javax.accessibility.AccessibleValue; import javax.swing.JComponent; import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.plaf.TableHeaderUI; public class JTableHeader extends JComponent { - protected class AccessibleJTableHeader + protected class AccessibleJTableHeader extends AccessibleJComponent { - protected class AccessibleJTableHeaderEntry + protected class AccessibleJTableHeaderEntry extends AccessibleContext + implements Accessible, AccessibleComponent { - } + public void addFocusListener(FocusListener l) + { + throw new Error("not implemented"); + } + public void addPropertyChangeListener(PropertyChangeListener l) + { + throw new Error("not implemented"); + } + public boolean contains(Point p) + { + throw new Error("not implemented"); + } + public AccessibleAction getAccessibleAction() + { + throw new Error("not implemented"); + } + public Accessible getAccessibleAt(Point p) + { + throw new Error("not implemented"); + } + public Accessible getAccessibleChild(int i) + { + throw new Error("not implemented"); + } + public int getAccessibleChildrenCount() + { + throw new Error("not implemented"); + } + public AccessibleComponent getAccessibleComponent() + { + throw new Error("not implemented"); + } + public AccessibleContext getAccessibleContext() + { + throw new Error("not implemented"); + } + public String getAccessibleDescription() + { + throw new Error("not implemented"); + } + public int getAccessibleIndexInParent() + { + throw new Error("not implemented"); + } + public String getAccessibleName() + { + throw new Error("not implemented"); + } + public AccessibleRole getAccessibleRole() + { + throw new Error("not implemented"); + } + public AccessibleSelection getAccessibleSelection() + { + throw new Error("not implemented"); + } + public AccessibleStateSet getAccessibleStateSet() + { + throw new Error("not implemented"); + } + public AccessibleText getAccessibleText() + { + throw new Error("not implemented"); + } + public AccessibleValue getAccessibleValue() + { + throw new Error("not implemented"); + } + public Color getBackground() + { + throw new Error("not implemented"); + } + public Rectangle getBounds() + { + throw new Error("not implemented"); + } + public Cursor getCursor() + { + throw new Error("not implemented"); + } + public Font getFont() + { + throw new Error("not implemented"); + } + public FontMetrics getFontMetrics(Font f) + { + throw new Error("not implemented"); + } + public Color getForeground() + { + throw new Error("not implemented"); + } + public Locale getLocale() + { + throw new Error("not implemented"); + } + public Point getLocation() + { + throw new Error("not implemented"); + } + public Point getLocationOnScreen() + { + throw new Error("not implemented"); + } + public Dimension getSize() + { + throw new Error("not implemented"); + } + public boolean isEnabled() + { + throw new Error("not implemented"); + } + public boolean isFocusTraversable() + { + throw new Error("not implemented"); + } + public boolean isShowing() + { + throw new Error("not implemented"); + } + public boolean isVisible() + { + throw new Error("not implemented"); + } + public void removeFocusListener(FocusListener l) + { + throw new Error("not implemented"); + } + public void removePropertyChangeListener(PropertyChangeListener l) + { + throw new Error("not implemented"); + } + public void requestFocus() + { + throw new Error("not implemented"); + } + public void setAccessibleDescription(String s) + { + throw new Error("not implemented"); + } + public void setAccessibleName(String s) + { + throw new Error("not implemented"); + } + public void setBackground(Color c) + { + throw new Error("not implemented"); + } + public void setBounds(Rectangle r) + { + throw new Error("not implemented"); + } + public void setCursor(Cursor c) + { + throw new Error("not implemented"); + } + public void setEnabled(boolean b) + { + throw new Error("not implemented"); + } + public void setFont(Font f) + { + throw new Error("not implemented"); + } + public void setForeground(Color c) + { + throw new Error("not implemented"); + } + public void setLocation(Point p) + { + throw new Error("not implemented"); + } + public void setSize(Dimension d) + { + throw new Error("not implemented"); + } + public void setVisible(boolean b) + { + throw new Error("not implemented"); + } + }; } private static final long serialVersionUID = 5144633983372967710L; - protected TableColumnModel columnModel; - protected TableColumn draggedColumn; - protected int draggedDistance; - protected boolean reorderingAllowed; - protected boolean resizingAllowed; - protected TableColumn resizingColumn; - protected JTable table; - protected boolean updateTableInRealTime; + /** + * The accessibleContext property. + */ + AccessibleContext accessibleContext; + + /** + * The columnModel property. + */ + TableColumnModel columnModel; + + /** + * The draggedColumn property. + */ + TableColumn draggedColumn; + + /** + * The draggedDistance property. + */ + int draggedDistance; + + /** + * The opaque property. + */ + boolean opaque; + + /** + * The reorderingAllowed property. + */ + boolean reorderingAllowed; + + /** + * The resizingAllowed property. + */ + boolean resizingAllowed; + + /** + * The resizingColumn property. + */ + TableColumn resizingColumn; + + /** + * The table property. + */ + JTable table; + + /** + * The updateTableInRealTime property. + */ + boolean updateTableInRealTime; + + TableCellRenderer cellRenderer; + + public JTableHeader() + { + this(null); + } + + public JTableHeader(TableColumnModel cm) + { + accessibleContext = new AccessibleJTableHeader(); + columnModel = cm == null ? createDefaultTableColumnModel() : cm; + draggedColumn = null; + draggedDistance = 0; + opaque = true; + reorderingAllowed = true; + resizingAllowed = true; + resizingColumn = null; + table = null; + updateTableInRealTime = true; + cellRenderer = createDefaultRenderer(); + updateUI(); + } + + protected TableColumnModel createDefaultTableColumnModel() + { + return new DefaultTableColumnModel(); + } + + + /** + * Get the value of the {@link #accessibleContext} property. + * + * @return The current value of the property + */ + public AccessibleContext getAccessibleContext() + { + return accessibleContext; + } + + /** + * Get the value of the {@link #columnModel} property. + * + * @return The current value of the property + */ + public TableColumnModel getColumnModel() + { + return columnModel; + } + + /** + * Get the value of the {@link #draggedColumn} property. + * + * @return The current value of the property + */ + public TableColumn getDraggedColumn() + { + return draggedColumn; + } + + /** + * Get the value of the {@link #draggedDistance} property. + * + * @return The current value of the property + */ + public int getDraggedDistance() + { + return draggedDistance; + } + + /** + * Get the value of the {@link #reorderingAllowed} property. + * + * @return The current value of the property + */ + public boolean getReorderingAllowed() + { + return reorderingAllowed; + } + + /** + * Get the value of the {@link #resizingAllowed} property. + * + * @return The current value of the property + */ + public boolean getResizingAllowed() + { + return resizingAllowed; + } + + /** + * Get the value of the {@link #resizingColumn} property. + * + * @return The current value of the property + */ + public TableColumn getResizingColumn() + { + return resizingColumn; + } + + /** + * Get the value of the {@link #table} property. + * + * @return The current value of the property + */ + public JTable getTable() + { + return table; + } + + /** + * Get the value of the {@link #updateTableInRealTime} property. + * + * @return The current value of the property + */ + public boolean getUpdateTableInRealTime() + { + return updateTableInRealTime; + } + + /** + * Get the value of the {@link #opaque} property. + * + * @return The current value of the property + */ + public boolean isOpaque() + { + return opaque; + } + + /** + * Set the value of the {@link #columnModel} property. + * + * @param c The new value of the property + */ + public void setColumnModel(TableColumnModel c) + { + columnModel = c; + } + + /** + * Set the value of the {@link #draggedColumn} property. + * + * @param d The new value of the property + */ + public void setDraggedColumn(TableColumn d) + { + draggedColumn = d; + } + + /** + * Set the value of the {@link #draggedDistance} property. + * + * @param d The new value of the property + */ + public void setDraggedDistance(int d) + { + draggedDistance = d; + } + + /** + * Set the value of the {@link #opaque} property. + * + * @param o The new value of the property + */ + public void setOpaque(boolean o) + { + opaque = o; + } + + /** + * Set the value of the {@link #reorderingAllowed} property. + * + * @param r The new value of the property + */ + public void setReorderingAllowed(boolean r) + { + reorderingAllowed = r; + } + + /** + * Set the value of the {@link #resizingAllowed} property. + * + * @param r The new value of the property + */ + public void setResizingAllowed(boolean r) + { + resizingAllowed = r; + } + + /** + * Set the value of the {@link #resizingColumn} property. + * + * @param r The new value of the property + */ + public void setResizingColumn(TableColumn r) + { + resizingColumn = r; + } + + /** + * Set the value of the {@link #table} property. + * + * @param t The new value of the property + */ + public void setTable(JTable t) + { + table = t; + } + + /** + * Set the value of the {@link #updateTableInRealTime} property. + * + * @param u The new value of the property + */ + public void setUpdateTableInRealTime(boolean u) + { + updateTableInRealTime = u; + } + + protected TableCellRenderer createDefaultRenderer() + { + return new DefaultTableCellRenderer(); + } + + public TableCellRenderer getDefaultRenderer() + { + return cellRenderer; + } + + public Rectangle getHeaderRect(int column) + { + Rectangle r = getTable().getCellRect(-1, column, true); + r.height = getHeight(); + return r; + } + + protected String paramString() + { + return "JTableHeader"; + } + + // UI support + + public String getUIClassID() + { + return "TableHeaderUI"; + } + + public TableHeaderUI getUI() + { + return (TableHeaderUI) ui; + } + + public void setUI(TableHeaderUI u) + { + super.setUI(u); + } + + public void updateUI() + { + setUI((TableHeaderUI) UIManager.getUI(this)); + } + } diff --git a/libjava/javax/swing/table/TableColumn.java b/libjava/javax/swing/table/TableColumn.java index 39ae1bd5d0b..02ef7f8009e 100644 --- a/libjava/javax/swing/table/TableColumn.java +++ b/libjava/javax/swing/table/TableColumn.java @@ -285,23 +285,19 @@ public class TableColumn return headerValue; } - /** - * setHeaderRenderer - * @param headerRenderer TODO - */ - public void setHeaderRenderer(TableCellRenderer headerRenderer) + /** + * setHeaderRenderer + * @param headerRenderer TODO + */ + public void setHeaderRenderer(TableCellRenderer renderer) { - // Variables - TableCellRenderer oldRenderer; - - // Get Old Renderer - oldRenderer = this.headerRenderer; - - // Set Property - this.headerRenderer = headerRenderer; - - // Notify Listeners of change - firePropertyChange(HEADER_RENDERER_PROPERTY, oldRenderer, headerRenderer); + if (headerRenderer == renderer) + return; + + TableCellRenderer oldRenderer = headerRenderer; + headerRenderer = renderer; + firePropertyChange(HEADER_RENDERER_PROPERTY, + oldRenderer, headerRenderer); } /** @@ -313,23 +309,19 @@ public class TableColumn return headerRenderer; } - /** - * setCellRenderer - * @param cellRenderer TODO - */ - public void setCellRenderer(TableCellRenderer cellRenderer) + /** + * setCellRenderer + * @param cellRenderer TODO + */ + public void setCellRenderer(TableCellRenderer renderer) { - // Variables - TableCellRenderer oldRenderer; - - // Get Old Renderer - oldRenderer = this.cellRenderer; - - // Set Property - this.cellRenderer = cellRenderer; - - // Notify Listeners of change - firePropertyChange(CELL_RENDERER_PROPERTY, oldRenderer, cellRenderer); + if (cellRenderer == renderer) + return; + + TableCellRenderer oldRenderer = cellRenderer; + cellRenderer = renderer; + firePropertyChange(CELL_RENDERER_PROPERTY, + oldRenderer, cellRenderer); } /** @@ -359,27 +351,25 @@ public class TableColumn return cellEditor; } - /** - * setWidth - * @param width TODO - */ - public void setWidth(int width) + /** + * setWidth + * @param newWidth TODO + */ + public void setWidth(int newWidth) { - // Variables - int oldWidth; + int oldWidth = width; - // Get Old Width - oldWidth = this.width; - - // Adjust Width within Limits - if (width < minWidth) - this.width = minWidth; - else if (width > maxWidth) - this.width = maxWidth; + if (newWidth < minWidth) + width = minWidth; + else if (newWidth > maxWidth) + width = maxWidth; else - this.width = width; + width = newWidth; + + if (width == oldWidth) + return; - firePropertyChange(COLUMN_WIDTH_PROPERTY, oldWidth, this.width); + firePropertyChange(COLUMN_WIDTH_PROPERTY, oldWidth, width); } /** diff --git a/libjava/javax/swing/text/AbstractDocument.java b/libjava/javax/swing/text/AbstractDocument.java index c1ea098c0a9..a7c8c907e60 100644 --- a/libjava/javax/swing/text/AbstractDocument.java +++ b/libjava/javax/swing/text/AbstractDocument.java @@ -38,6 +38,7 @@ exception statement from your version. */ package javax.swing.text; import java.io.Serializable; +import java.util.Collections; import java.util.Dictionary; import java.util.Enumeration; import java.util.EventListener; @@ -63,33 +64,37 @@ public abstract class AbstractDocument public static final String ParagraphElementName = "paragraph"; public static final String SectionElementName = "section"; public static final String ElementNameAttribute = "$ename"; + Content content; + AttributeContext context; protected EventListenerList listenerList = new EventListenerList(); protected AbstractDocument(Content doc) { - this(doc, null); + this(doc, StyleContext.getDefaultStyleContext()); } - protected AbstractDocument(Content doc, AttributeContext context) + protected AbstractDocument(Content doc, AttributeContext ctx) { content = doc; + context = ctx; } - // these still need to be implemented by a derived class: + // These still need to be implemented by a derived class: public abstract Element getParagraphElement(int pos); public abstract Element getDefaultRootElement(); - protected Element createBranchElement(Element parent, AttributeSet a) + protected Element createBranchElement(Element parent, + AttributeSet attributes) { - return new BranchElement(parent, a, 0, 0); + return new BranchElement(parent, attributes); } - protected Element createLeafElement(Element parent, AttributeSet a, int p0, - int p1) + protected Element createLeafElement(Element parent, AttributeSet attributes, + int start, int end) { - return new LeafElement(parent, a, p0, p1 - p0); + return new LeafElement(parent, attributes, start, end); } public Position createPosition(final int offset) throws BadLocationException @@ -145,7 +150,7 @@ public abstract class AbstractDocument protected AttributeContext getAttributeContext() { - return null; + return context; } public Element getBidiRootElement() @@ -170,7 +175,13 @@ public abstract class AbstractDocument public Position getEndPosition() { - return null; + return new Position() + { + public int getOffset() + { + return getLength(); + } + }; } public int getLength() @@ -190,12 +201,20 @@ public abstract class AbstractDocument public Element[] getRootElements() { - return null; + Element[] elements = new Element[1]; + elements[0] = getDefaultRootElement(); + return elements; } public Position getStartPosition() { - return null; + return new Position() + { + public int getOffset() + { + return 0; + } + }; } public String getText(int offset, int length) throws BadLocationException @@ -203,34 +222,25 @@ public abstract class AbstractDocument return content.getString(offset, length); } - public void getText(int offset, int length, Segment txt) + public void getText(int offset, int length, Segment segment) throws BadLocationException { - String a = getText(offset, length); - - if (a == null) - { - txt.offset = 0; - txt.count = 0; - txt.array = new char[0]; - - return; - } - - txt.offset = offset; - txt.count = length; - - char[] chars = new char[a.length()]; - - a.getChars(0, a.length(), chars, 0); - - txt.array = chars; + content.getChars(offset, length, segment); } - public void insertString(int offs, String str, AttributeSet a) + public void insertString(int offset, String text, AttributeSet attributes) throws BadLocationException { - content.insertString(offs, str); + // Just return when no text to insert was given. + if (text == null || text.length() == 0) + return; + + DefaultDocumentEvent event = + new DefaultDocumentEvent(offset, text.length(), + DocumentEvent.EventType.INSERT); + content.insertString(offset, text); + insertUpdate(event, attributes); + fireInsertUpdate(event); } protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr) @@ -255,6 +265,26 @@ public abstract class AbstractDocument public void remove(int offset, int length) throws BadLocationException { + DefaultDocumentEvent event = + new DefaultDocumentEvent(offset, length, + DocumentEvent.EventType.REMOVE); + removeUpdate(event); + content.remove(offset, length); + postRemoveUpdate(event); + fireRemoveUpdate(event); + } + + /** + * Replaces some text in the document. + * + * @since 1.4 + */ + public void replace(int offset, int length, String text, + AttributeSet attributes) + throws BadLocationException + { + remove(offset, length); + insertString(offset, text, attributes); } /** @@ -375,47 +405,51 @@ public abstract class AbstractDocument } public abstract class AbstractElement - implements Element, TreeNode, Serializable + implements Element, MutableAttributeSet, TreeNode, Serializable { private static final long serialVersionUID = 1265312733007397733L; int count; int offset; - AttributeSet attr; - Vector elts = new Vector(); - String name; - Element parent; - Vector kids = new Vector(); + + AttributeSet attributes; + + Element element_parent; + Vector element_children; + TreeNode tree_parent; + Vector tree_children; public AbstractElement(Element p, AttributeSet s) { - parent = p; - attr = s; + element_parent = p; + attributes = s; } + // TreeNode implementation + public Enumeration children() { - return kids.elements(); + return Collections.enumeration(tree_children); } - + public boolean getAllowsChildren() { return true; } - + public TreeNode getChildAt(int index) { - return (TreeNode) kids.elementAt(index); + return (TreeNode) tree_children.get(index); } - + public int getChildCount() { - return kids.size(); + return tree_children.size(); } - + public int getIndex(TreeNode node) { - return kids.indexOf(node); + return tree_children.indexOf(node); } public TreeNode getParent() @@ -423,55 +457,134 @@ public abstract class AbstractDocument return tree_parent; } + public abstract boolean isLeaf(); + + + // MutableAttributeSet support + + public void addAttribute(Object name, Object value) + { + attributes = getAttributeContext().addAttribute(attributes, name, value); + } + + public void addAttributes(AttributeSet attrs) + { + attributes = getAttributeContext().addAttributes(attributes, attrs); + } + + public void removeAttribute(Object name) + { + attributes = getAttributeContext().removeAttribute(attributes, name); + } + + public void removeAttributes(AttributeSet attrs) + { + attributes = getAttributeContext().removeAttributes(attributes, attrs); + } + + public void removeAttributes(Enumeration names) + { + attributes = getAttributeContext().removeAttributes(attributes, names); + } + + public void setResolveParent(AttributeSet parent) + { + attributes = getAttributeContext().addAttribute(attributes, ResolveAttribute, parent); + } + + + // AttributeSet interface support + + public boolean containsAttribute(Object name, Object value) + { + return attributes.containsAttribute(name, value); + } + + public boolean containsAttributes(AttributeSet attrs) + { + return attributes.containsAttributes(attrs); + } + + public AttributeSet copyAttributes() + { + return attributes.copyAttributes(); + } + + public Object getAttribute(Object key) + { + return attributes.getAttribute(key); + } + + public int getAttributeCount() + { + return attributes.getAttributeCount(); + } + + public Enumeration getAttributeNames() + { + return attributes.getAttributeNames(); + } + + public AttributeSet getResolveParent() + { + return attributes.getResolveParent(); + } + + public boolean isDefined(Object attrName) + { + return attributes.isDefined(attrName); + } + + public boolean isEqual(AttributeSet attrs) + { + return attributes.isEqual(attrs); + } + + // Element interface support + public AttributeSet getAttributes() { - return attr; + return attributes; } public Document getDocument() { return AbstractDocument.this; } - + public Element getElement(int index) { - return (Element) elts.elementAt(index); + return (Element) element_children.get(index); } - + public String getName() { - return name; + return (String) getAttribute(NameAttribute); } - + public Element getParentElement() { - return parent; + return element_parent; } - - public abstract boolean isLeaf(); - + public abstract int getEndOffset(); - + public abstract int getElementCount(); - + public abstract int getElementIndex(int offset); - + public abstract int getStartOffset(); } public class BranchElement extends AbstractElement { private static final long serialVersionUID = -8595176318868717313L; - private int start; - private int end; + private Vector children = new Vector(); - public BranchElement(Element parent, AttributeSet attributes, int start, - int end) + public BranchElement(Element parent, AttributeSet attributes) { super(parent, attributes); - this.start = start; - this.end = end; } public Enumeration children() @@ -486,6 +599,9 @@ public abstract class AbstractDocument public Element getElement(int index) { + if (index < 0 || index >= children.size()) + return null; + return (Element) children.get(index); } @@ -496,12 +612,20 @@ public abstract class AbstractDocument public int getElementIndex(int offset) { - return children.indexOf(positionToElement(offset)); + if (children.size() == 0) + return 0; + + Element element = positionToElement(offset); + + if (element == null) + return 0; + + return children.indexOf(element); } public int getEndOffset() { - return end; + return ((Element) children.lastElement()).getEndOffset(); } public String getName() @@ -511,7 +635,7 @@ public abstract class AbstractDocument public int getStartOffset() { - return start; + return ((Element) children.firstElement()).getStartOffset(); } public boolean isLeaf() @@ -554,8 +678,18 @@ public abstract class AbstractDocument implements DocumentEvent { private static final long serialVersionUID = -7406103236022413522L; - public int len; - public int off; + + private int offset; + private int length; + private DocumentEvent.EventType type; + + public DefaultDocumentEvent(int offset, int length, + DocumentEvent.EventType type) + { + this.offset = offset; + this.length = length; + this.type = type; + } public Document getDocument() { @@ -564,17 +698,17 @@ public abstract class AbstractDocument public int getLength() { - return len; + return length; } public int getOffset() { - return off; + return offset; } public DocumentEvent.EventType getType() { - return null; + return type; } public DocumentEvent.ElementChange getChange(Element elem) @@ -584,8 +718,43 @@ public abstract class AbstractDocument } public static class ElementEdit extends AbstractUndoableEdit + implements DocumentEvent.ElementChange { private static final long serialVersionUID = -1216620962142928304L; + + private Element elem; + private int index; + private Element[] removed; + private Element[] added; + + public ElementEdit(Element elem, int index, + Element[] removed, Element[] added) + { + this.elem = elem; + this.index = index; + this.removed = removed; + this.added = added; + } + + public Element[] getChildrenAdded() + { + return added; + } + + public Element[] getChildrenRemoved() + { + return removed; + } + + public Element getElement() + { + return elem; + } + + public int getIndex() + { + return index; + } } public class LeafElement extends AbstractElement diff --git a/libjava/javax/swing/text/AttributeSet.java b/libjava/javax/swing/text/AttributeSet.java index 3c31767cf3a..3f38a4cd249 100644 --- a/libjava/javax/swing/text/AttributeSet.java +++ b/libjava/javax/swing/text/AttributeSet.java @@ -56,14 +56,17 @@ public interface AttributeSet static interface ParagraphAttribute { } - - boolean containsAttribute(Object name, Object value); - boolean containsAttributes(AttributeSet attributes); - AttributeSet copyAttributes(); - Object getAttribute(Object key); - int getAttributeCount(); - Enumeration getAttributeNames(); - AttributeSet getResolveParent(); - boolean isDefined(Object attrName); - boolean isEqual(AttributeSet attr); + + static Object NameAttribute = StyleConstants.NameAttribute; + static Object ResolveAttribute = StyleConstants.ResolveAttribute; + + boolean containsAttribute(Object name, Object value); + boolean containsAttributes(AttributeSet attributes); + AttributeSet copyAttributes(); + Object getAttribute(Object key); + int getAttributeCount(); + Enumeration getAttributeNames(); + AttributeSet getResolveParent(); + boolean isDefined(Object attrName); + boolean isEqual(AttributeSet attr); } diff --git a/libjava/javax/swing/text/DefaultCaret.java b/libjava/javax/swing/text/DefaultCaret.java index 968bf1ffdf6..516f0726ba0 100644 --- a/libjava/javax/swing/text/DefaultCaret.java +++ b/libjava/javax/swing/text/DefaultCaret.java @@ -61,15 +61,15 @@ public class DefaultCaret extends Rectangle protected ChangeEvent changeEvent = new ChangeEvent(this); protected EventListenerList listenerList = new EventListenerList(); - Color color = new Color(0, 0, 0); - JTextComponent parent; - Point magic = null; - int mark = 0; - boolean vis_sel = true; - int blink = 500; - int dot = 0; - boolean vis = true; - + private JTextComponent textComponent; + + private boolean selectionVisible = true; + private int blinkRate = 0; + private int dot = 0; + private int mark = 0; + private Point magicCaretPosition = null; + private boolean visible = true; + private Object highlightEntry; public void mouseDragged(MouseEvent event) { @@ -117,27 +117,29 @@ public class DefaultCaret extends Rectangle public void deinstall(JTextComponent c) { - parent.removeFocusListener(this); - parent.removeMouseListener(this); - parent = null; + textComponent.removeFocusListener(this); + textComponent.removeMouseListener(this); + textComponent.removeMouseMotionListener(this); + textComponent = null; } public void install(JTextComponent c) { - parent.addFocusListener(this); - parent.addMouseListener(this); - parent = c; + textComponent = c; + textComponent.addFocusListener(this); + textComponent.addMouseListener(this); + textComponent.addMouseMotionListener(this); repaint(); } public void setMagicCaretPosition(Point p) { - magic = p; + magicCaretPosition = p; } public Point getMagicCaretPosition() { - return magic; + return magicCaretPosition; } public int getMark() @@ -145,27 +147,92 @@ public class DefaultCaret extends Rectangle return mark; } + private void handleHighlight() + { + Highlighter highlighter = textComponent.getHighlighter(); + + if (highlighter == null) + return; + + int p0 = Math.min(dot, mark); + int p1 = Math.max(dot, mark); + + if (selectionVisible && p0 != p1) + { + try + { + if (highlightEntry == null) + highlightEntry = highlighter.addHighlight(p0, p1, getSelectionPainter()); + else + highlighter.changeHighlight(highlightEntry, p0, p1); + } + catch (BadLocationException e) + { + // This should never happen. + throw new InternalError(); + } + } + else + { + if (highlightEntry != null) + { + highlighter.removeHighlight(highlightEntry); + highlightEntry = null; + } + } + } + public void setSelectionVisible(boolean v) { - vis_sel = v; + if (selectionVisible == v) + return; + + selectionVisible = v; + handleHighlight(); repaint(); } public boolean isSelectionVisible() { - return vis_sel; + return selectionVisible; } protected final void repaint() { - if (parent != null) - parent.repaint(); + if (textComponent != null) + textComponent.repaint(); } public void paint(Graphics g) { - g.setColor(color); - g.drawLine(x, y, x, y + height); + if (textComponent == null) + return; + + int dot = getDot(); + Rectangle rect = null; + + try + { + rect = textComponent.modelToView(dot); + } + catch (BadLocationException e) + { + // This should never happen as dot should be always valid. + return; + } + + if (rect == null) + return; + + // First we need to delete the old caret. + // FIXME: Implement deleting of old caret. + + // Now draw the caret on the new position if visible. + if (visible) + { + g.setColor(textComponent.getCaretColor()); + g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height); + } } public EventListener[] getListeners(Class listenerType) @@ -198,17 +265,17 @@ public class DefaultCaret extends Rectangle protected final JTextComponent getComponent() { - return parent; + return textComponent; } public int getBlinkRate() { - return blink; + return blinkRate; } public void setBlinkRate(int rate) { - blink = rate; + blinkRate = rate; } public int getDot() @@ -218,23 +285,32 @@ public class DefaultCaret extends Rectangle public void moveDot(int dot) { - setDot(dot); + this.dot = dot; + handleHighlight(); + repaint(); } public void setDot(int dot) { this.dot = dot; + this.mark = dot; + handleHighlight(); repaint(); } public boolean isVisible() { - return vis; + return visible; } public void setVisible(boolean v) { - vis = v; + visible = v; repaint(); } + + protected Highlighter.HighlightPainter getSelectionPainter() + { + return DefaultHighlighter.DefaultPainter; + } } diff --git a/libjava/javax/swing/text/DefaultEditorKit.java b/libjava/javax/swing/text/DefaultEditorKit.java index 8611de5a0eb..03d4ef3040e 100644 --- a/libjava/javax/swing/text/DefaultEditorKit.java +++ b/libjava/javax/swing/text/DefaultEditorKit.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing.text; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; @@ -48,7 +50,121 @@ import javax.swing.JEditorPane; public class DefaultEditorKit extends EditorKit { + public static class BeepAction + extends TextAction + { + public BeepAction() + { + super(beepAction); + } + + public void actionPerformed(ActionEvent event) + { + Toolkit.getDefaultToolkit().beep(); + } + } + + public static class CopyAction + extends TextAction + { + public CopyAction() + { + super(copyAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + + public static class CutAction + extends TextAction + { + public CutAction() + { + super(cutAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + + public static class DefaultKeyTypedAction + extends TextAction + { + public DefaultKeyTypedAction() + { + super(defaultKeyTypedAction); + } + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + try + { + t.getDocument().insertString(t.getCaret().getDot(), event.getActionCommand(), null); + t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1, + t.getDocument().getEndPosition().getOffset())); + t.repaint(); + } + catch (BadLocationException be) + { + // FIXME: we're not authorized to throw this.. swallow it? + } + } + } + } + + public static class InsertBreakAction + extends TextAction + { + public InsertBreakAction() + { + super(insertBreakAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + + public static class InsertContentAction + extends TextAction + { + public InsertContentAction() + { + super(insertContentAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + + public static class InsertTabAction + extends TextAction + { + public InsertTabAction() + { + super(insertTabAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + + public static class PasteAction + extends TextAction + { + public PasteAction() + { + super(pasteAction); + } + public void actionPerformed(ActionEvent event) + { + } + } + private static final long serialVersionUID = 9017245433028523428L; + public static final String backwardAction = "caret-backward"; public static final String beepAction = "beep"; public static final String beginAction = "caret-begin"; @@ -104,6 +220,113 @@ public class DefaultEditorKit extends EditorKit { } + private static Action[] defaultActions = + new Action[] { + new BeepAction(), + new CopyAction(), + new CutAction(), + new DefaultKeyTypedAction(), + new InsertBreakAction(), + new InsertContentAction(), + new InsertTabAction(), + new PasteAction(), + new TextAction(deleteNextCharAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + try + { + int pos = t.getCaret().getDot(); + if (pos < t.getDocument().getEndPosition().getOffset()) + { + t.getDocument().remove(t.getCaret().getDot(), 1); + t.repaint(); + } + } + catch (BadLocationException e) + { + // FIXME: we're not authorized to throw this.. swallow it? + } + } + } + }, + new TextAction(deletePrevCharAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + try + { + int pos = t.getCaret().getDot(); + if (pos > t.getDocument().getStartPosition().getOffset()) + { + t.getDocument().remove(pos - 1, 1); + t.getCaret().setDot(pos - 1); + t.repaint(); + } + } + catch (BadLocationException e) + { + // FIXME: we're not authorized to throw this.. swallow it? + } + } + } + }, + new TextAction(backwardAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + t.getCaret().setDot(Math.max(t.getCaret().getDot() - 1, + t.getDocument().getStartPosition().getOffset())); + } + } + }, + new TextAction(forwardAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + t.getCaret().setDot(Math.min(t.getCaret().getDot() + 1, + t.getDocument().getEndPosition().getOffset())); + } + } + }, + new TextAction(selectionBackwardAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + t.getCaret().moveDot(Math.max(t.getCaret().getDot() - 1, + t.getDocument().getStartPosition().getOffset())); + } + } + }, + new TextAction(selectionForwardAction) + { + public void actionPerformed(ActionEvent event) + { + JTextComponent t = getTextComponent(event); + if (t != null) + { + t.getCaret().moveDot(Math.min(t.getCaret().getDot() + 1, + t.getDocument().getEndPosition().getOffset())); + } + } + }, + }; + /** * Called when the kit is being removed from the JEditorPane. */ @@ -116,19 +339,19 @@ public class DefaultEditorKit extends EditorKit } public Caret createCaret() - { - return null; - } + { + return new DefaultCaret(); + } public Document createDefaultDocument() - { - return new PlainDocument(); - } - + { + return new PlainDocument(); + } + public Action[] getActions() - { - return null; - } + { + return defaultActions; + } public String getContentType() { diff --git a/libjava/javax/swing/text/DefaultHighlighter.java b/libjava/javax/swing/text/DefaultHighlighter.java index 003d17d1a8e..234fcad60ff 100644 --- a/libjava/javax/swing/text/DefaultHighlighter.java +++ b/libjava/javax/swing/text/DefaultHighlighter.java @@ -38,7 +38,9 @@ exception statement from your version. */ package javax.swing.text; +import java.awt.Color; import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.Shape; import java.util.Vector; @@ -48,6 +50,87 @@ import javax.swing.text.View; public class DefaultHighlighter extends LayeredHighlighter { + public static class DefaultHighlightPainter + extends LayerPainter + { + private Color color; + + public DefaultHighlightPainter(Color c) + { + super(); + color = c; + } + + public Color getColor() + { + return color; + } + + private void paintHighlight(Graphics g, Rectangle rect) + { + g.fillRect(rect.x, rect.y, rect.width, rect.height); + } + + public void paint(Graphics g, int p0, int p1, Shape bounds, + JTextComponent c) + { + Rectangle r0 = null; + Rectangle r1 = null; + Rectangle rect = bounds.getBounds(); + + try + { + r0 = c.modelToView(p0); + r1 = c.modelToView(p1); + } + catch (BadLocationException e) + { + // This should never occur. + return; + } + + if (r0 == null || r1 == null) + return; + + if (color == null) + g.setColor(c.getSelectionColor()); + else + g.setColor(color); + + // Check if only one line to highlight. + if (r0.y == r1.y) + { + r0.width = r1.x - r0.x; + paintHighlight(g, r0); + return; + } + + // First line, from p0 to end-of-line. + r0.width = rect.x + rect.width - r0.x; + paintHighlight(g, r0); + + // FIXME: All the full lines in between, if any (assumes that all lines + // have the same height -- not a good assumption with JEditorPane/JTextPane). + r0.y += r0.height; + r0.x = rect.x; + + while (r0.y < r1.y) + { + paintHighlight(g, r0); + r0.y += r0.height; + } + + // Last line, from beginnin-of-line to p1. + paintHighlight(g, r1); + } + + public Shape paintLayer(Graphics g, int p0, int p1, Shape bounds, + JTextComponent c, View view) + { + throw new InternalError(); + } + } + private class HighlightEntry { int p0; @@ -77,6 +160,12 @@ public class DefaultHighlighter extends LayeredHighlighter } } + /** + * @specnote final as of 1.4 + */ + public static final LayeredHighlighter.LayerPainter DefaultPainter = + new DefaultHighlightPainter(null); + private JTextComponent textComponent; private Vector highlights = new Vector(); @@ -146,5 +235,16 @@ public class DefaultHighlighter extends LayeredHighlighter public void paint(Graphics g) { + // Check if there are any highlights. + if (highlights.size() == 0) + return; + + Shape bounds = textComponent.getBounds(); + + for (int index = 0; index < highlights.size(); ++index) + { + HighlightEntry entry = (HighlightEntry) highlights.get(index); + entry.painter.paint(g, entry.p0, entry.p1, bounds, textComponent); + } } } diff --git a/libjava/javax/swing/text/FieldView.java b/libjava/javax/swing/text/FieldView.java index 29a00acfa3c..06514b73f14 100644 --- a/libjava/javax/swing/text/FieldView.java +++ b/libjava/javax/swing/text/FieldView.java @@ -90,8 +90,14 @@ public class FieldView extends PlainView return axis = axis == X_AXIS ? 1 : 0; } + public Shape modelToView(int pos, Shape a, Position.Bias bias) + throws BadLocationException + { + return super.modelToView(pos, a, bias); + } + public void paint(Graphics g, Shape s) { - drawLine(0, g, 0, 0); + super.paint(g, s); } } diff --git a/libjava/javax/swing/text/JTextComponent.java b/libjava/javax/swing/text/JTextComponent.java index e44c5296d86..ea69f5d16d9 100644 --- a/libjava/javax/swing/text/JTextComponent.java +++ b/libjava/javax/swing/text/JTextComponent.java @@ -46,13 +46,20 @@ import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.InputMethodListener; +import java.awt.event.KeyEvent; + +import java.util.Enumeration; +import java.util.Hashtable; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; import javax.accessibility.AccessibleStateSet; import javax.accessibility.AccessibleText; +import javax.swing.Action; +import javax.swing.ActionMap; import javax.swing.Icon; +import javax.swing.InputMap; import javax.swing.JComponent; import javax.swing.JViewport; import javax.swing.KeyStroke; @@ -62,6 +69,8 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.plaf.ActionMapUIResource; +import javax.swing.plaf.InputMapUIResource; import javax.swing.plaf.TextUI; @@ -283,11 +292,505 @@ public abstract class JTextComponent extends JComponent } } + /** + * According to this + * report, a pair of private classes wraps a {@link + * javax.swing.text.Keymap} in the new {@link InputMap} / {@link + * ActionMap} interfaces, such that old Keymap-using code can make use of + * the new framework.

    + * + *

    A little bit of experimentation with these classes reveals the following + * structure: + * + *

      + * + *
    • KeymapWrapper extends {@link InputMap} and holds a reference to + * the underlying {@link Keymap}.
    • + * + *
    • KeymapWrapper maps {@link KeyStroke} objects to {@link Action} + * objects, by delegation to the underlying {@link Keymap}.
    • + * + *
    • KeymapActionMap extends {@link ActionMap} also holds a reference to + * the underlying {@link Keymap} but only appears to use it for listing + * its keys.
    • + * + *
    • KeymapActionMap maps all {@link Action} objects to + * themselves, whether they exist in the underlying {@link + * Keymap} or not, and passes other objects to the parent {@link + * ActionMap} for resolving. + * + *
    + */ + + private class KeymapWrapper extends InputMap + { + Keymap map; + + public KeymapWrapper(Keymap k) + { + map = k; + } + + public int size() + { + return map.getBoundKeyStrokes().length + super.size(); + } + + public Object get(KeyStroke ks) + { + Action mapped = null; + Keymap m = map; + while(mapped == null && m != null) + { + mapped = m.getAction(ks); + if (mapped == null && ks.getKeyEventType() == KeyEvent.KEY_TYPED) + mapped = m.getDefaultAction(); + if (mapped == null) + m = m.getResolveParent(); + } + + if (mapped == null) + return super.get(ks); + else + return mapped; + } + + public KeyStroke[] keys() + { + KeyStroke[] superKeys = super.keys(); + KeyStroke[] mapKeys = map.getBoundKeyStrokes(); + KeyStroke[] bothKeys = new KeyStroke[superKeys.length + mapKeys.length]; + for (int i = 0; i < superKeys.length; ++i) + bothKeys[i] = superKeys[i]; + for (int i = 0; i < mapKeys.length; ++i) + bothKeys[i + superKeys.length] = mapKeys[i]; + return bothKeys; + } + + public KeyStroke[] allKeys() + { + KeyStroke[] superKeys = super.allKeys(); + KeyStroke[] mapKeys = map.getBoundKeyStrokes(); + KeyStroke[] bothKeys = new KeyStroke[superKeys.length + mapKeys.length]; + for (int i = 0; i < superKeys.length; ++i) + bothKeys[i] = superKeys[i]; + for (int i = 0; i < mapKeys.length; ++i) + bothKeys[i + superKeys.length] = mapKeys[i]; + return bothKeys; + } + } + + private class KeymapActionMap extends ActionMap + { + Keymap map; + + public KeymapActionMap(Keymap k) + { + map = k; + } + + public Action get(Object cmd) + { + if (cmd instanceof Action) + return (Action) cmd; + else + return super.get(cmd); + } + + public int size() + { + return map.getBoundKeyStrokes().length + super.size(); + } + + public Object[] keys() + { + Object[] superKeys = super.keys(); + Object[] mapKeys = map.getBoundKeyStrokes(); + Object[] bothKeys = new Object[superKeys.length + mapKeys.length]; + for (int i = 0; i < superKeys.length; ++i) + bothKeys[i] = superKeys[i]; + for (int i = 0; i < mapKeys.length; ++i) + bothKeys[i + superKeys.length] = mapKeys[i]; + return bothKeys; + } + + public Object[] allKeys() + { + Object[] superKeys = super.allKeys(); + Object[] mapKeys = map.getBoundKeyStrokes(); + Object[] bothKeys = new Object[superKeys.length + mapKeys.length]; + for (int i = 0; i < superKeys.length; ++i) + bothKeys[i] = superKeys[i]; + for (int i = 0; i < mapKeys.length; ++i) + bothKeys[i + superKeys.length] = mapKeys[i]; + return bothKeys; + } + + } + + static class DefaultKeymap implements Keymap + { + String name; + Keymap parent; + Hashtable map; + Action defaultAction; + + public DefaultKeymap(String name) + { + this.name = name; + this.map = new Hashtable(); + } + + public void addActionForKeyStroke(KeyStroke key, Action a) + { + map.put(key, a); + } + + /** + * Looks up a KeyStroke either in the current map or the parent Keymap; + * does not return the default action if lookup fails. + * + * @param key The KeyStroke to look up an Action for. + * + * @return The mapping for key, or null + * if no mapping exists in this Keymap or any of its parents. + */ + public Action getAction(KeyStroke key) + { + if (map.containsKey(key)) + return (Action) map.get(key); + else if (parent != null) + return parent.getAction(key); + else + return null; + } + + public Action[] getBoundActions() + { + Action [] ret = new Action[map.size()]; + Enumeration e = map.elements(); + int i = 0; + while (e.hasMoreElements()) + { + ret[i++] = (Action) e.nextElement(); + } + return ret; + } + + public KeyStroke[] getBoundKeyStrokes() + { + KeyStroke [] ret = new KeyStroke[map.size()]; + Enumeration e = map.keys(); + int i = 0; + while (e.hasMoreElements()) + { + ret[i++] = (KeyStroke) e.nextElement(); + } + return ret; + } + + public Action getDefaultAction() + { + return defaultAction; + } + + public KeyStroke[] getKeyStrokesForAction(Action a) + { + int i = 0; + Enumeration e = map.keys(); + while (e.hasMoreElements()) + { + if (map.get(e.nextElement()).equals(a)) + ++i; + } + KeyStroke [] ret = new KeyStroke[i]; + i = 0; + e = map.keys(); + while (e.hasMoreElements()) + { + KeyStroke k = (KeyStroke) e.nextElement(); + if (map.get(k).equals(a)) + ret[i++] = k; + } + return ret; + } + + public String getName() + { + return name; + } + + public Keymap getResolveParent() + { + return parent; + } + + public boolean isLocallyDefined(KeyStroke key) + { + return map.containsKey(key); + } + + public void removeBindings() + { + map.clear(); + } + + public void removeKeyStrokeBinding(KeyStroke key) + { + map.remove(key); + } + + public void setDefaultAction(Action a) + { + defaultAction = a; + } + + public void setResolveParent(Keymap p) + { + parent = p; + } + + } + private static final long serialVersionUID = -8796518220218978795L; public static final String DEFAULT_KEYMAP = "default"; public static final String FOCUS_ACCELERATOR_KEY = "focusAcceleratorKey"; + + private static Hashtable keymaps = new Hashtable(); + private Keymap keymap; + + /** + * Get a Keymap from the global keymap table, by name. + * + * @param n The name of the Keymap to look up + * + * @return A Keymap associated with the provided name, or + * null if no such Keymap exists + * + * @see #addKeymap() + * @see #removeKeymap() + * @see #keymaps + */ + public static Keymap getKeymap(String n) + { + return (Keymap) keymaps.get(n); + } + + /** + * Remove a Keymap from the global Keymap table, by name. + * + * @param n The name of the Keymap to remove + * + * @return The keymap removed from the global table + * + * @see #addKeymap() + * @see #getKeymap() + * @see #keymaps + */ + public static Keymap removeKeymap(String n) + { + Keymap km = (Keymap) keymaps.get(n); + keymaps.remove(n); + return km; + } + + /** + * Create a new Keymap with a specific name and parent, and add the new + * Keymap to the global keymap table. The name may be null, + * in which case the new Keymap will not be added to the global + * Keymap table. The parent may also be null, which is + * harmless. + * + * @param n The name of the new Keymap, or null + * @param parent The parent of the new Keymap, or null + * + * @return The newly created Keymap + * + * @see #removeKeymap() + * @see #getKeymap() + * @see #keymaps + */ + public static Keymap addKeymap(String n, Keymap parent) + { + Keymap k = new DefaultKeymap(n); + k.setResolveParent(parent); + if (n != null) + keymaps.put(n, k); + return k; + } + /** + * Get the current Keymap of this component. + * + * @return The component's current Keymap + * + * @see #setKeymap() + * @see #keymap + */ + Keymap getKeymap() + { + return keymap; + } + + /** + * Set the current Keymap of this component, installing appropriate + * {@link KeymapWrapper} and {@link KeymapActionMap} objects in the + * {@link InputMap} and {@link ActionMap} parent chains, respectively, + * and fire a property change event with name "keymap". + * + * @see #getKeymap() + * @see #keymap + */ + public void setKeymap(Keymap k) + { + + // phase 1: replace the KeymapWrapper entry in the InputMap chain. + // the goal here is to always maintain the following ordering: + // + // [InputMap]? -> [KeymapWrapper]? -> [InputMapUIResource]* + // + // that is to say, component-specific InputMaps need to remain children + // of Keymaps, and Keymaps need to remain children of UI-installed + // InputMaps (and the order of each group needs to be preserved, of + // course). + + KeymapWrapper kw = (k == null ? null : new KeymapWrapper(k)); + InputMap childInputMap = getInputMap(JComponent.WHEN_FOCUSED); + if (childInputMap == null) + setInputMap(JComponent.WHEN_FOCUSED, kw); + else + { + while (childInputMap.getParent() != null + && !(childInputMap.getParent() instanceof KeymapWrapper) + && !(childInputMap.getParent() instanceof InputMapUIResource)) + childInputMap = childInputMap.getParent(); + + // option 1: there is nobody to replace at the end of the chain + if (childInputMap.getParent() == null) + childInputMap.setParent(kw); + + // option 2: there is already a KeymapWrapper in the chain which + // needs replacing (possibly with its own parents, possibly without) + else if (childInputMap.getParent() instanceof KeymapWrapper) + { + if (kw == null) + childInputMap.setParent(childInputMap.getParent().getParent()); + else + { + kw.setParent(childInputMap.getParent().getParent()); + childInputMap.setParent(kw); + } + } + + // option 3: there is an InputMapUIResource in the chain, which marks + // the place where we need to stop and insert ourselves + else if (childInputMap.getParent() instanceof InputMapUIResource) + { + if (kw != null) + { + kw.setParent(childInputMap.getParent()); + childInputMap.setParent(kw); + } + } + } + + // phase 2: replace the KeymapActionMap entry in the ActionMap chain + + KeymapActionMap kam = (k == null ? null : new KeymapActionMap(k)); + ActionMap childActionMap = getActionMap(); + if (childActionMap == null) + setActionMap(kam); + else + { + while (childActionMap.getParent() != null + && !(childActionMap.getParent() instanceof KeymapActionMap) + && !(childActionMap.getParent() instanceof ActionMapUIResource)) + childActionMap = childActionMap.getParent(); + + // option 1: there is nobody to replace at the end of the chain + if (childActionMap.getParent() == null) + childActionMap.setParent(kam); + + // option 2: there is already a KeymapActionMap in the chain which + // needs replacing (possibly with its own parents, possibly without) + else if (childActionMap.getParent() instanceof KeymapActionMap) + { + if (kam == null) + childActionMap.setParent(childActionMap.getParent().getParent()); + else + { + kam.setParent(childActionMap.getParent().getParent()); + childActionMap.setParent(kam); + } + } + + // option 3: there is an ActionMapUIResource in the chain, which marks + // the place where we need to stop and insert ourselves + else if (childActionMap.getParent() instanceof ActionMapUIResource) + { + if (kam != null) + { + kam.setParent(childActionMap.getParent()); + childActionMap.setParent(kam); + } + } + } + + // phase 3: update the explicit keymap field + + Keymap old = keymap; + keymap = k; + firePropertyChange("keymap", old, k); + } + + /** + * Resolves a set of bindings against a set of actions and inserts the + * results into a {@link Keymap}. Specifically, for each provided binding + * b, if there exists a provided action a such + * that a.getValue(Action.NAME) == b.ActionName then an + * entry is added to the Keymap mapping b to + * a. + * + * @param map The Keymap to add new mappings to + * @param bindings The set of bindings to add to the Keymap + * @param actions The set of actions to resolve binding names against + * + * @see Action#NAME + * @see Action#getValue() + * @see KeyBinding#ActionName + */ + public static void loadKeymap(Keymap map, + JTextComponent.KeyBinding[] bindings, + Action[] actions) + { + Hashtable acts = new Hashtable(actions.length); + for (int i = 0; i < actions.length; ++i) + acts.put(actions[i].getValue(Action.NAME), actions[i]); + for (int i = 0; i < bindings.length; ++i) + if (acts.containsKey(bindings[i].actionName)) + map.addActionForKeyStroke(bindings[i].key, (Action) acts.get(bindings[i].actionName)); + } + + /** + * Returns the set of available Actions this component's associated + * editor can run. Equivalent to calling + * getUI().getEditorKit().getActions(). This set of Actions + * is a reasonable value to provide as a parameter to {@link + * #loadKeymap()}, when resolving a set of {@link #KeyBinding} objects + * against this component. + * + * @return The set of available Actions on this component's {@link EditorKit} + * + * @see TextUI#getEditorKit() + * @see EditorKit#getActions() + */ + public Action[] getActions() + { + return getUI().getEditorKit(this).getActions(); + } + private Document doc; private Caret caret; private Highlighter highlighter; @@ -296,19 +799,47 @@ public abstract class JTextComponent extends JComponent private Color selectedTextColor; private Color selectionColor; private boolean editable; + private Insets margin; /** * Creates a new JTextComponent instance. */ public JTextComponent() { + Keymap defkeymap = getKeymap(DEFAULT_KEYMAP); + boolean creatingKeymap = false; + if (defkeymap == null) + { + defkeymap = addKeymap(DEFAULT_KEYMAP, null); + defkeymap.setDefaultAction(new DefaultEditorKit.DefaultKeyTypedAction()); + creatingKeymap = true; + } + + setFocusable(true); enableEvents(AWTEvent.KEY_EVENT_MASK); updateUI(); + + // need to do this after updateUI() + if (creatingKeymap) + loadKeymap(defkeymap, + new KeyBinding[] { + new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), + DefaultEditorKit.backwardAction), + new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), + DefaultEditorKit.forwardAction), + new KeyBinding(KeyStroke.getKeyStroke("typed \b"), + DefaultEditorKit.deletePrevCharAction), + new KeyBinding(KeyStroke.getKeyStroke("typed \u007f"), + DefaultEditorKit.deleteNextCharAction) + }, + getActions()); } - public void setDocument(Document s) + public void setDocument(Document newDoc) { - doc = s; + Document oldDoc = doc; + doc = newDoc; + firePropertyChange("document", oldDoc, newDoc); revalidate(); repaint(); } @@ -328,18 +859,22 @@ public abstract class JTextComponent extends JComponent return null; } + public void setMargin(Insets m) + { + margin = m; + } + public Insets getMargin() { - // FIXME: Not implemented. - return null; + return margin; } public void setText(String text) { try { - getDocument().remove(0, doc.getLength()); - getDocument().insertString(0, text, null); + doc.remove(0, doc.getLength()); + doc.insertString(0, text, null); } catch (BadLocationException e) { @@ -488,8 +1023,16 @@ public abstract class JTextComponent extends JComponent */ public void setCaret(Caret newCaret) { - firePropertyChange("caret", caret, newCaret); + if (caret != null) + caret.deinstall(this); + + Caret oldCaret = caret; caret = newCaret; + + if (caret != null) + caret.install(this); + + firePropertyChange("caret", oldCaret, newCaret); } public Color getCaretColor() @@ -499,8 +1042,9 @@ public abstract class JTextComponent extends JComponent public void setCaretColor(Color newColor) { - firePropertyChange("caretColor", caretColor, newColor); + Color oldCaretColor = caretColor; caretColor = newColor; + firePropertyChange("caretColor", oldCaretColor, newColor); } public Color getDisabledTextColor() @@ -510,8 +1054,9 @@ public abstract class JTextComponent extends JComponent public void setDisabledTextColor(Color newColor) { - firePropertyChange("disabledTextColor", caretColor, newColor); + Color oldColor = disabledTextColor; disabledTextColor = newColor; + firePropertyChange("disabledTextColor", oldColor, newColor); } public Color getSelectedTextColor() @@ -521,8 +1066,9 @@ public abstract class JTextComponent extends JComponent public void setSelectedTextColor(Color newColor) { - firePropertyChange("selectedTextColor", caretColor, newColor); + Color oldColor = selectedTextColor; selectedTextColor = newColor; + firePropertyChange("selectedTextColor", oldColor, newColor); } public Color getSelectionColor() @@ -532,8 +1078,9 @@ public abstract class JTextComponent extends JComponent public void setSelectionColor(Color newColor) { - firePropertyChange("selectionColor", caretColor, newColor); + Color oldColor = selectionColor; selectionColor = newColor; + firePropertyChange("selectionColor", oldColor, newColor); } /** @@ -584,8 +1131,16 @@ public abstract class JTextComponent extends JComponent public void setHighlighter(Highlighter newHighlighter) { - firePropertyChange("highlighter", highlighter, newHighlighter); + if (highlighter != null) + highlighter.deinstall(this); + + Highlighter oldHighlighter = highlighter; highlighter = newHighlighter; + + if (highlighter != null) + highlighter.install(this); + + firePropertyChange("highlighter", oldHighlighter, newHighlighter); } /** @@ -773,4 +1328,9 @@ public abstract class JTextComponent extends JComponent { return (InputMethodListener[]) getListeners(InputMethodListener.class); } + + public Rectangle modelToView(int position) throws BadLocationException + { + return getUI().modelToView(this, position); + } } diff --git a/libjava/javax/swing/text/PlainView.java b/libjava/javax/swing/text/PlainView.java index 229c7e193b0..3dd8fe44842 100644 --- a/libjava/javax/swing/text/PlainView.java +++ b/libjava/javax/swing/text/PlainView.java @@ -39,6 +39,8 @@ exception statement from your version. */ package javax.swing.text; import java.awt.Color; +import java.awt.Component; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Rectangle; @@ -48,12 +50,70 @@ import java.awt.Shape; public class PlainView extends View implements TabExpander { + private Color selectedColor; + private Color unselectedColor; + private Font font; + protected FontMetrics metrics; public PlainView(Element elem) { super(elem); } + + /** + * @since 1.4 + */ + protected void updateMetrics() + { + Component component = getContainer(); + Font font = component.getFont(); + + if (this.font != font) + { + this.font = font; + metrics = component.getFontMetrics(font); + } + } + + /** + * @since 1.4 + */ + protected Rectangle lineToRect(Shape a, int line) + { + // Ensure metrics are up-to-date. + updateMetrics(); + + Rectangle rect = a.getBounds(); + int fontHeight = metrics.getHeight(); + return new Rectangle(rect.x, rect.y + (line * fontHeight), + rect.width, fontHeight); + } + + public Shape modelToView(int position, Shape a, Position.Bias b) + throws BadLocationException + { + Document document = getDocument(); + + // Get rectangle of the line containing position. + int lineIndex = getElement().getElementIndex(position); + Rectangle rect = lineToRect(a, lineIndex); + + // Get the rectangle for position. + Element line = getElement().getElement(lineIndex); + int lineStart = line.getStartOffset(); + Segment segment = new Segment(); + document.getText(lineStart, position - lineStart, segment); + int xoffset = Utilities.getTabbedTextWidth(segment, metrics, rect.x, + this, lineStart); + + // Calc the real rectangle. + rect.x += xoffset; + rect.width = 1; + rect.height = metrics.getHeight(); + + return rect; + } public void drawLine(int lineIndex, Graphics g, int x, int y) { @@ -73,30 +133,31 @@ public class PlainView extends View public int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException { - String text = getDocument().getText(p0, p1); - g.setColor(Color.WHITE); - g.drawString(text, x, y); - return metrics.stringWidth(text); + g.setColor(selectedColor); + Segment segment = new Segment(); + getDocument().getText(p0, p1 - p0, segment); + return Utilities.drawTabbedText(segment, x, y, g, this, 0); } public int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException { - String text = getDocument().getText(p0, p1); - g.setColor(Color.BLACK); - g.drawString(text, x, y); - return metrics.stringWidth(text); + g.setColor(unselectedColor); + Segment segment = new Segment(); + getDocument().getText(p0, p1 - p0, segment); + return Utilities.drawTabbedText(segment, x, y, g, this, 0); } public void paint(Graphics g, Shape s) { - System.out.println("Michael: PlainView.paint"); + JTextComponent textComponent = (JTextComponent) getContainer(); + + g.setFont(textComponent.getFont()); + selectedColor = textComponent.getSelectedTextColor(); + unselectedColor = textComponent.getForeground(); Rectangle rect = s.getBounds(); - g.setColor(Color.WHITE); - g.fillRect(rect.x, rect.y, rect.width, rect.height); - // FIXME: Text may be scrolled. drawLine(0, g, rect.x, rect.y); } @@ -106,10 +167,18 @@ public class PlainView extends View return 8; } + /** + * Returns the next tab stop position after a given reference position. + * + * This implementation ignores the tabStop argument. + * + * @param x the current x position in pixels + * @param tabStop the position within the text stream that the tab occured at + */ public float nextTabStop(float x, int tabStop) { - System.out.println("Michael: PlainView.nextTabpStop: missing implementation"); - return x; + float tabSizePixels = getTabSize() + metrics.charWidth('m'); + return (float) (Math.floor(x / tabSizePixels) + 1) * tabSizePixels; } public float getPreferredSpan(int axis) @@ -119,4 +188,5 @@ public class PlainView extends View return 10; } -} \ No newline at end of file +} + diff --git a/libjava/javax/swing/text/Segment.java b/libjava/javax/swing/text/Segment.java index 69e2fecfc38..218768e05e2 100644 --- a/libjava/javax/swing/text/Segment.java +++ b/libjava/javax/swing/text/Segment.java @@ -39,10 +39,12 @@ package javax.swing.text; import java.text.CharacterIterator; - public class Segment implements Cloneable, CharacterIterator { + private boolean partialReturn; + private int current; + public char[] array; public int count; public int offset; @@ -67,61 +69,108 @@ public class Segment catch (CloneNotSupportedException e) { return null; - } + } } + + public char current() + { + if (count == 0 + || current >= getEndIndex()) + return DONE; - public char current() - { - return array[getIndex()]; - } + return array[current]; + } - public char first() - { - offset = getBeginIndex(); - return array[offset]; - } + public char first() + { + if (count == 0) + return DONE; + + current = getBeginIndex(); + return array[current]; + } + + public int getBeginIndex() + { + return offset; + } + + public int getEndIndex() + { + return offset + count; + } + + public int getIndex() + { + return current; + } + + public char last() + { + if (count == 0) + return DONE; - public int getBeginIndex() - { - return offset; - } + current = getEndIndex() - 1; + return array[current]; + } + + public char next() + { + if (count == 0) + return DONE; + + if ((current + 1) >= getEndIndex()) + { + current = getEndIndex(); + return DONE; + } - public int getEndIndex() - { - return offset + count; - } + current++; + return array[current]; + } - public int getIndex() - { - return offset; - } + public char previous() + { + if (count == 0 + || current == getBeginIndex()) + return DONE; + + current--; + return array[current]; + } - public char last() - { - offset = getEndIndex() - 1; - return array[offset]; - } + public char setIndex(int position) + { + if (position < getBeginIndex() + || position > getEndIndex()) + throw new IllegalArgumentException(); - public char next() - { - offset++; - return array[offset]; - } + current = position; - public char previous() - { - offset--; - return array[offset]; - } + if (position == getEndIndex()) + return DONE; + + return array[current]; + } - public char setIndex(int position) - { - offset = position; - return array[offset]; - } + public String toString() + { + return new String(array, offset, count); + } - public String toString() - { - return new String(array, offset, count); - } + /** + * @since 1.4 + */ + public void setPartialReturn(boolean p) + { + partialReturn = p; + } + + /** + * @since 1.4 + */ + public boolean isPartialReturn() + { + return partialReturn; + } } diff --git a/libjava/javax/swing/text/TextAction.java b/libjava/javax/swing/text/TextAction.java index 5fee0e8640d..029eed9c5e4 100644 --- a/libjava/javax/swing/text/TextAction.java +++ b/libjava/javax/swing/text/TextAction.java @@ -54,7 +54,7 @@ public abstract class TextAction extends AbstractAction */ public TextAction(String name) { - // TODO + super(name); } /** @@ -64,7 +64,11 @@ public abstract class TextAction extends AbstractAction */ protected final JTextComponent getTextComponent(ActionEvent event) { - return null; // TODO + if (event.getSource() != null && + event.getSource() instanceof JTextComponent) + return (JTextComponent) event.getSource(); + else + return getFocusedComponent(); } /** diff --git a/libjava/javax/swing/text/View.java b/libjava/javax/swing/text/View.java index 6c5a9c296dd..730753a342b 100644 --- a/libjava/javax/swing/text/View.java +++ b/libjava/javax/swing/text/View.java @@ -161,8 +161,49 @@ public abstract class View implements SwingConstants public View createFragment(int p0, int p1) { - // The default implementation doesnt support fragmentation. + // The default implementation doesn't support fragmentation. return this; - } + } + + public int getStartOffset() + { + return elt.getStartOffset(); + } + + public int getEndOffset() + { + return elt.getEndOffset(); + } + + public Shape getChildAllocation(int index, Shape a) + { + return null; + } + + /** + * @since 1.4 + */ + public int getViewIndex(float x, float y, Shape allocation) + { + return -1; + } + + /** + * @since 1.4 + */ + public String getToolTipText(float x, float y, Shape allocation) + { + int index = getViewIndex(x, y, allocation); + + if (index < -1) + return null; + + Shape childAllocation = getChildAllocation(index, allocation); + + if (childAllocation.getBounds().contains(x, y)) + return getView(index).getToolTipText(x, y, childAllocation); + + return null; + } } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c index cc09102debd..c10b945ab6b 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c @@ -54,6 +54,8 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri jint *metrics; struct peerfont *pf = NULL; FT_Matrix mat; + double pointsize; + FT_Face face; pf = NSA_GET_FONT_PTR(env, font); g_assert (pf != NULL); @@ -68,7 +70,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri #define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0)) #define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0) - double pointsize = pango_font_description_get_size (pf->desc); + pointsize = pango_font_description_get_size (pf->desc); pointsize /= (double) PANGO_SCALE; mat.xx = DOUBLE_TO_16_16(1); @@ -76,7 +78,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetri mat.yx = DOUBLE_TO_16_16(0); mat.yy = DOUBLE_TO_16_16(1); - FT_Face face = pango_ft2_font_get_face (pf->font); + face = pango_ft2_font_get_face (pf->font); FT_Set_Transform(face, &mat, NULL); FT_Set_Char_Size( face, DOUBLE_TO_26_6 (pointsize), diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c index 864e465871b..a79ed5eb093 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c @@ -94,15 +94,13 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II /* copy the native state of the peer (GtkWidget *) to the native state of the graphics object */ -JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject obj, jobject peer) { struct graphics *g = (struct graphics *) malloc (sizeof (struct graphics)); void *ptr; GtkWidget *widget; GdkColor color; - jintArray array; - jint *rgb; ptr = NSA_GET_PTR (env, peer); g->x_offset = g->y_offset = 0; @@ -133,16 +131,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lg gdk_threads_leave (); - array = (*env)->NewIntArray (env, 3); - rgb = (*env)->GetIntArrayElements (env, array, NULL); - rgb[0] = color.red >> 8; - rgb[1] = color.green >> 8; - rgb[2] = color.blue >> 8; - (*env)->ReleaseIntArrayElements (env, array, rgb, 0); - NSA_SET_PTR (env, obj, g); - - return array; } JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose @@ -323,7 +312,111 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyPixmap gdk_flush (); gdk_threads_leave (); } + +static void flip_pixbuf (GdkPixbuf *pixbuf, + jboolean flip_x, + jboolean flip_y, + jint width, + jint height) +{ + gint src_rs; + guchar *src_pix; + + src_rs = gdk_pixbuf_get_rowstride (pixbuf); + src_pix = gdk_pixbuf_get_pixels (pixbuf); + + if (flip_x) + { + gint i, channels; + guchar buf[4]; + + channels = gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3; + + for (i = 0; i < height; i++) + { + guchar *left = src_pix + i * src_rs; + guchar *right = left + channels * (width - 1); + while (left < right) + { + g_memmove (buf, left, channels); + g_memmove (left, right, channels); + g_memmove (right, buf, channels); + left += channels; + right -= channels; + } + } + } + + if (flip_y) + { + guchar *top = src_pix; + guchar *bottom = top + (height - 1) * src_rs; + gpointer buf = g_malloc (src_rs); + + while (top < bottom) + { + g_memmove (buf, top, src_rs); + g_memmove (top, bottom, src_rs); + g_memmove (bottom, buf, src_rs); + top += src_rs; + bottom -= src_rs; + } + + g_free (buf); + } +} +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyAndScalePixmap + (JNIEnv *env, jobject obj, jobject offscreen, jboolean flip_x, jboolean flip_y, + jint src_x, jint src_y, jint src_width, jint src_height, + jint dest_x, jint dest_y, jint dest_width, jint dest_height) +{ + struct graphics *g1, *g2; + GdkPixbuf *buf_src, *buf_dest; + + g1 = (struct graphics *) NSA_GET_PTR (env, obj); + g2 = (struct graphics *) NSA_GET_PTR (env, offscreen); + + gdk_threads_enter (); + + buf_src = gdk_pixbuf_get_from_drawable (NULL, + g2->drawable, + g2->cm, + src_x, + src_y, + 0, + 0, + src_width, + src_height); + + buf_dest = gdk_pixbuf_scale_simple (buf_src, + dest_width, + dest_height, + GDK_INTERP_BILINEAR); + + if (flip_x || flip_y) + { + flip_pixbuf (buf_dest, flip_x, flip_y, dest_width, dest_height); + } + + gdk_pixbuf_render_to_drawable (buf_dest, + g1->drawable, + g1->gc, + 0, + 0, + dest_x, + dest_y, + dest_width, + dest_height, + GDK_RGB_DITHER_NORMAL, + 0, + 0); + + g_object_unref (G_OBJECT (buf_src)); + g_object_unref (G_OBJECT (buf_dest)); + + gdk_threads_leave (); +} diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c index 733461dcfc1..e4d223c543d 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c @@ -400,7 +400,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable struct graphics2d *src = NULL, *dst = NULL; gint s_height, s_width, d_height, d_width, height, width; cairo_matrix_t *matrix; - GdkGC *gc; cairo_operator_t tmp_op; gdk_threads_enter(); @@ -443,41 +442,12 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable gdk_threads_leave(); } -static jintArray -current_colors_of_widget (GtkWidget *widget, JNIEnv *env) -{ - GdkColor color; - jintArray array; - jint *rgb; - - g_assert (widget != NULL); - g_assert (env != NULL); - - color = widget->style->fg[GTK_STATE_NORMAL]; - array = (*env)->NewIntArray (env, 6); - - rgb = (*env)->GetIntArrayElements (env, array, NULL); - rgb[0] = color.red >> 8; - rgb[1] = color.green >> 8; - rgb[2] = color.blue >> 8; - - color = widget->style->bg[GTK_STATE_NORMAL]; - rgb[3] = color.red >> 8; - rgb[4] = color.green >> 8; - rgb[5] = color.blue >> 8; - - (*env)->ReleaseIntArrayElements (env, array, rgb, 0); - - return array; -} - -JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject obj, jobject peer) { struct graphics2d *gr = NULL; GtkWidget *widget = NULL; void *ptr = NULL; - jintArray color; gdk_threads_enter(); if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; } @@ -504,11 +474,8 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__ else init_graphics2d_as_pixbuf (gr); - color = current_colors_of_widget (widget, env); - NSA_SET_G2D_PTR (env, obj, gr); gdk_threads_leave(); - return color; } JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose @@ -637,20 +604,21 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient negate offsets. oh well. */ - - double a = (x2 - x1 == 0.) ? 0. : ((cyclic ? 3.0 : 2.0) / (x2 - x1)); - double c = (y2 - y1 == 0.) ? 0. : (1. / (y2 - y1)); - double dx = (x1 == 0.) ? 0. : 1. / x1; - double dy = (y1 == 0.) ? 0. : 1. / y1; - - cairo_matrix_set_affine (mat, - a, 0., - c, 0., - dx, dy); - - cairo_surface_set_matrix (surf, mat); - cairo_matrix_destroy (mat); - cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR); + { + double a = (x2 - x1 == 0.) ? 0. : ((cyclic ? 3.0 : 2.0) / (x2 - x1)); + double c = (y2 - y1 == 0.) ? 0. : (1. / (y2 - y1)); + double dx = (x1 == 0.) ? 0. : 1. / x1; + double dy = (y1 == 0.) ? 0. : 1. / y1; + + cairo_matrix_set_affine (mat, + a, 0., + c, 0., + dx, dy); + + cairo_surface_set_matrix (surf, mat); + cairo_matrix_destroy (mat); + cairo_surface_set_filter (surf, CAIRO_FILTER_BILINEAR); + } /* FIXME: repeating gradients (not to mention hold gradients) don't seem to work. */ /* cairo_surface_set_repeat (surf, cyclic ? 1 : 0); */ @@ -783,7 +751,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix jint i, px; gdk_threads_enter(); - if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return; } + if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return NULL; } gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj); g_assert (gr != NULL); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c index 97e49625cb7..f58c289aa40 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c @@ -1,5 +1,5 @@ /* gdkpixbufdecoder.c - Copyright (C) 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,36 +35,38 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ - -#include +#include +#include #include #include -#include "gtkpeer.h" +#include +#include "native_state.h" #include "gnu_java_awt_peer_gtk_GdkPixbufDecoder.h" -struct state_table *native_pixbufdecoder_state_table; - -#define NSA_PB_INIT(env, clazz) \ - native_pixbufdecoder_state_table = init_state_table (env, clazz) +#include +#include -#define NSA_GET_PB_PTR(env, obj) \ - get_state (env, obj, native_pixbufdecoder_state_table) - -#define NSA_SET_PB_PTR(env, obj, ptr) \ - set_state (env, obj, native_pixbufdecoder_state_table, (void *)ptr) +struct state_table *native_pixbufdecoder_state_table; -#define NSA_DEL_PB_PTR(env, obj) \ - remove_state_slot (env, obj, native_pixbufdecoder_state_table) +/* Union used for type punning. */ +union env_union +{ + void **void_env; + JNIEnv **jni_env; +}; +static JavaVM *vm; -jmethodID areaPreparedID; -jmethodID areaUpdatedID; +static jmethodID areaPreparedID; +static jmethodID areaUpdatedID; static void area_prepared (GdkPixbufLoader *loader, jobject *decoder) { + JNIEnv *env; + union env_union e; jint width, height; GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); @@ -78,11 +80,13 @@ area_prepared (GdkPixbufLoader *loader, g_assert (decoder != NULL); - (*gdk_env)->CallVoidMethod (gdk_env, - *decoder, - areaPreparedID, - width, height); - + e.jni_env = &env; + (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); + (*env)->CallVoidMethod (env, + *decoder, + areaPreparedID, + width, height); + gdk_threads_enter (); } @@ -92,6 +96,8 @@ area_updated (GdkPixbufLoader *loader, gint width, gint height, jobject *decoder) { + JNIEnv *env; + union env_union e; jint stride_bytes, stride_pixels, n_channels, n_pixels; int i, px; jintArray jpixels; @@ -114,8 +120,10 @@ area_updated (GdkPixbufLoader *loader, n_pixels = height * stride_pixels; gdk_pixels = gdk_pixbuf_get_pixels (pixbuf); - jpixels = (*gdk_env)->NewIntArray (gdk_env, n_pixels); - java_pixels = (*gdk_env)->GetIntArrayElements (gdk_env, jpixels, NULL); + e.jni_env = &env; + (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); + jpixels = (*env)->NewIntArray (env, n_pixels); + java_pixels = (*env)->GetIntArrayElements (env, jpixels, NULL); memcpy (java_pixels, gdk_pixels + (y * stride_bytes), @@ -141,22 +149,27 @@ area_updated (GdkPixbufLoader *loader, gdk_threads_leave (); - (*gdk_env)->ReleaseIntArrayElements (gdk_env, jpixels, java_pixels, 0); - (*gdk_env)->CallVoidMethod (gdk_env, - *decoder, - areaUpdatedID, - (jint) x, (jint) y, - (jint) width, (jint) height, - jpixels, - stride_pixels); + (*env)->ReleaseIntArrayElements (env, jpixels, java_pixels, 0); + (*env)->CallVoidMethod (env, + *decoder, + areaUpdatedID, + (jint) x, (jint) y, + (jint) width, (jint) height, + jpixels, + stride_pixels); gdk_threads_enter (); } static void closed (GdkPixbufLoader *loader __attribute__((unused)), jobject *decoder) { + JNIEnv *env; + union env_union e; + e.jni_env = &env; + (*vm)->GetEnv (vm, e.void_env, JNI_VERSION_1_1); + gdk_threads_leave (); - (*gdk_env)->DeleteGlobalRef (gdk_env, *decoder); + (*env)->DeleteGlobalRef (env, *decoder); free (decoder); gdk_threads_enter (); } @@ -187,6 +200,8 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initState JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_initStaticState (JNIEnv *env, jclass clazz) { + (*env)->GetJavaVM(env, &vm); + areaPreparedID = (*env)->GetMethodID (env, clazz, "areaPrepared", "(II)V"); @@ -223,14 +238,14 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkPixbufDecoder_pumpBytes if (len < 1) return; - bytes = (*gdk_env)->GetByteArrayElements (gdk_env, jarr, NULL); + bytes = (*env)->GetByteArrayElements (env, jarr, NULL); g_assert (bytes != NULL); loader = (GdkPixbufLoader *)NSA_GET_PB_PTR (env, obj); g_assert (loader != NULL); gdk_threads_enter (); - gdk_pixbuf_loader_write (loader, bytes, len, NULL); + gdk_pixbuf_loader_write (loader, (const guchar *) bytes, len, NULL); gdk_threads_leave (); - (*gdk_env)->ReleaseByteArrayElements (gdk_env, jarr, bytes, 0); + (*env)->ReleaseByteArrayElements (env, jarr, bytes, 0); } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c index d9647e9ba10..08d38b5871d 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c @@ -42,20 +42,23 @@ exception statement from your version. */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkButtonPeer_create - (JNIEnv *env, jobject obj) + (JNIEnv *env, jobject obj, jstring label) { + const char *c_label; GtkWidget *button; - /* Create global reference and save it for future use */ NSA_SET_GLOBAL_REF (env, obj); + c_label = (*env)->GetStringUTFChars (env, label, NULL); + gdk_threads_enter (); - - button = gtk_button_new(); + + button = gtk_button_new_with_label (c_label); gtk_widget_show (button); gdk_threads_leave (); + (*env)->ReleaseStringUTFChars (env, label, c_label); NSA_SET_PTR (env, obj, button); } @@ -102,7 +105,7 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetLabel gdk_threads_enter (); label = gtk_bin_get_child (GTK_BIN (ptr)); - gtk_label_set_text (GTK_LABEL(label), text); + gtk_label_set_text (GTK_LABEL (label), text); gdk_threads_leave (); @@ -126,9 +129,6 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkSetFont label = gtk_bin_get_child (GTK_BIN (ptr)); - if (!label) - return; - font_desc = pango_font_description_from_string (font_name); pango_font_description_set_size (font_desc, size * dpi_conversion_factor); @@ -165,9 +165,6 @@ Java_gnu_java_awt_peer_gtk_GtkButtonPeer_gtkWidgetSetForeground label = gtk_bin_get_child (GTK_BIN(ptr)); - if (!label) - return; - gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color); gtk_widget_modify_fg (label, GTK_STATE_ACTIVE, &color); gtk_widget_modify_fg (label, GTK_STATE_PRELIGHT, &color); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c index f5d7cfb89aa..4d5c8114cd7 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c @@ -43,12 +43,11 @@ exception statement from your version. */ static void item_toggled (GtkToggleButton *item, jobject peer); JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate - (JNIEnv *env, jobject obj, jobject group, jboolean state) +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_create + (JNIEnv *env, jobject obj, jobject group) { GtkWidget *button; - /* Create global reference and save it for future use */ NSA_SET_GLOBAL_REF (env, obj); gdk_threads_enter (); @@ -66,7 +65,6 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeCreate NSA_SET_PTR (env, group, button); } } - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), state); gdk_threads_leave (); @@ -130,6 +128,21 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_nativeSetCheckboxGroup NSA_SET_PTR (env, group, native_group); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkToggleButtonSetActive + (JNIEnv *env, jobject obj, jboolean is_active) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ptr), is_active); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont (JNIEnv *env, jobject obj, jstring name, jint style, jint size) @@ -171,26 +184,25 @@ Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetFont } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkSetLabel +Java_gnu_java_awt_peer_gtk_GtkCheckboxPeer_gtkButtonSetLabel (JNIEnv *env, jobject obj, jstring label) { - const char *str; - void *ptr; + const char *c_label; GtkWidget *label_widget; + void *ptr; ptr = NSA_GET_PTR (env, obj); - label_widget = gtk_bin_get_child (GTK_BIN(ptr)); - - str = (*env)->GetStringUTFChars (env, label, 0); + c_label = (*env)->GetStringUTFChars (env, label, NULL); gdk_threads_enter (); - gtk_label_set_label (GTK_LABEL (label_widget), str); + label_widget = gtk_bin_get_child (GTK_BIN (ptr)); + gtk_label_set_text (GTK_LABEL (label_widget), c_label); gdk_threads_leave (); - (*env)->ReleaseStringUTFChars (env, label, str); + (*env)->ReleaseStringUTFChars (env, label, c_label); } static void diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c index 9b262d33d7d..128443121b2 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c @@ -39,38 +39,27 @@ exception statement from your version. */ #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkChoicePeer.h" -static void connect_choice_item_selectable_hook (JNIEnv *env, - jobject peer_obj, - GtkItem *menuitem, - const char *label); +static void selection_changed (GtkComboBox *combobox, gpointer data); JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkChoicePeer_create (JNIEnv *env, jobject obj) { GtkWidget *menu; - GtkOptionMenu *option_menu; - GtkRequisition child_requisition; + GtkComboBox *combobox; - /* Create global reference and save it for future use */ NSA_SET_GLOBAL_REF (env, obj); gdk_threads_enter (); - option_menu = GTK_OPTION_MENU (gtk_option_menu_new ()); - menu = gtk_menu_new (); - gtk_widget_show (menu); + combobox = gtk_combo_box_new_text (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - - gtk_widget_size_request (gtk_menu_item_new_with_label (""), - &child_requisition); - option_menu->width = child_requisition.width; - option_menu->height = child_requisition.height; + g_signal_connect (combobox, "changed", + G_CALLBACK (selection_changed), obj); gdk_threads_leave (); - NSA_SET_PTR (env, obj, option_menu); + NSA_SET_PTR (env, obj, combobox); } JNIEXPORT void JNICALL @@ -78,45 +67,27 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_append (JNIEnv *env, jobject obj, jobjectArray items) { gpointer ptr; - GtkMenu *menu; jsize count, i; - int need_set_history = 0; ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); - menu = GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr))); - - /* Are we adding the first element? */ - if (gtk_option_menu_get_history (GTK_OPTION_MENU (ptr)) < 0) - need_set_history = 1; - count = (*env)->GetArrayLength (env, items); for (i = 0; i < count; i++) { jobject item; const char *label; - GtkWidget *menuitem; item = (*env)->GetObjectArrayElement (env, items, i); label = (*env)->GetStringUTFChars (env, item, NULL); - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_append (menu, menuitem); - gtk_widget_show (menuitem); - - connect_choice_item_selectable_hook (env, obj, - GTK_ITEM (menuitem), label); + gtk_combo_box_append_text (GTK_COMBO_BOX (ptr), label); (*env)->ReleaseStringUTFChars (env, item, label); } - /* If we just added the first element select it. */ - if (need_set_history) - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); - gdk_threads_leave (); } @@ -126,36 +97,13 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeAdd { void *ptr; const char *label; - GtkWidget *menu, *menuitem; - int current; - int need_set_history = 0; ptr = NSA_GET_PTR (env, obj); label = (*env)->GetStringUTFChars (env, item, 0); gdk_threads_enter (); - - current = gtk_option_menu_get_history (GTK_OPTION_MENU (ptr)); - - /* Are we adding the first element or below or at the currently - selected one? */ - if ((current < 0) || (current >= index)) - need_set_history = 1; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr)); - menuitem = gtk_menu_item_new_with_label (label); - gtk_menu_insert (GTK_MENU (menu), menuitem, index); - gtk_widget_show (menuitem); - - connect_choice_item_selectable_hook (env, obj, GTK_ITEM (menuitem), label); - - /* If we just added the first element select it. - If we added at of below the currently selected position make - the first item the selected one. */ - if (need_set_history) - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); - + gtk_combo_box_insert_text (GTK_COMBO_BOX (ptr), index, label); gdk_threads_leave (); (*env)->ReleaseStringUTFChars (env, item, label); @@ -166,50 +114,35 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemove (JNIEnv *env, jobject obj, jint index) { void *ptr; - GtkContainer *menu; - GtkWidget *menuitem; - GList *children; - int need_set_history = 0; - int i, from, to; ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); + gtk_combo_box_remove_text (GTK_COMBO_BOX (ptr), index); + gdk_threads_leave (); +} - menu = GTK_CONTAINER (gtk_option_menu_get_menu (GTK_OPTION_MENU (ptr))); - children = gtk_container_children (menu); +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeRemoveAll + (JNIEnv *env, jobject obj) +{ + void *ptr; + GtkTreeModel *model; + gint count, i; - if (index == -1) - { - /* Remove all elements (removeAll) */ - from = g_list_length (children) - 1; - to = 0; + ptr = NSA_GET_PTR (env, obj); - /* Select the first item to prevent spurious activate signals */ - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); - } - else - { - /* Remove the specific index element */ - from = index; - to = index; + gdk_threads_enter (); - /* Are we removing the currently selected element? */ - if (gtk_option_menu_get_history (GTK_OPTION_MENU (ptr)) == index) - need_set_history = 1; - } + model = gtk_combo_box_get_model (GTK_COMBO_BOX (ptr)); + count = gtk_tree_model_iter_n_children (model, NULL); - for (i = from; i >= to; i--) - { - menuitem = GTK_WIDGET (g_list_nth (children, i)->data); - gtk_container_remove (menu, menuitem); - gtk_widget_destroy (menuitem); - } + /* First, unselect everything, to avoid problems when removing items. */ + gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), -1); - /* If we just removed the currently selected element and there are - still elements left in the list, make the first item the selected one. */ - if (need_set_history && gtk_container_children (menu)) - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), 0); + for (i = count - 1; i >= 0; i--) { + gtk_combo_box_remove_text (GTK_COMBO_BOX (ptr), i); + } gdk_threads_leave (); } @@ -223,12 +156,12 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_select ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); - gtk_option_menu_set_history (GTK_OPTION_MENU (ptr), index); + gtk_combo_box_set_active (GTK_COMBO_BOX (ptr), index); gdk_threads_leave (); } JNIEXPORT jint JNICALL -Java_gnu_java_awt_peer_gtk_GtkChoicePeer_getHistory +Java_gnu_java_awt_peer_gtk_GtkChoicePeer_nativeGetSelected (JNIEnv *env, jobject obj) { void *ptr; @@ -237,58 +170,38 @@ Java_gnu_java_awt_peer_gtk_GtkChoicePeer_getHistory ptr = NSA_GET_PTR (env, obj); gdk_threads_enter (); - - index = gtk_option_menu_get_history (GTK_OPTION_MENU (ptr)); - + index = gtk_combo_box_get_active (GTK_COMBO_BOX (ptr)); gdk_threads_leave (); return index; } -static void -item_activate (GtkItem *item __attribute__((unused)), - struct item_event_hook_info *ie) +void selection_changed (GtkComboBox *combobox, jobject peer) { jstring label; - gdk_threads_leave (); + GtkTreeModel *model; + GtkTreeIter iter; + GValue value; + gchar *selected; + gint index; - label = (*gdk_env)->NewStringUTF (gdk_env, ie->label); - (*gdk_env)->CallVoidMethod (gdk_env, ie->peer_obj, - choicePostItemEventID, - label, - (jint) AWT_ITEM_SELECTED); - gdk_threads_enter (); -} + index = gtk_combo_box_get_active(combobox); -static void -item_removed (gpointer data, - GClosure gc __attribute__((unused))) -{ - struct item_event_hook_info *ie = data; - - free ((void *) ie->label); - free (ie); -} - -static void -connect_choice_item_selectable_hook (JNIEnv *env, - jobject peer_obj, - GtkItem *menuitem, - const char *label) -{ - struct item_event_hook_info *ie; - jobject *peer_objGlobPtr; + if (index >= 0) + { + model = gtk_combo_box_get_model (combobox); - ie = (struct item_event_hook_info *) - malloc (sizeof (struct item_event_hook_info)); + gtk_combo_box_get_active_iter (combobox, &iter); - peer_objGlobPtr = NSA_GET_GLOBAL_REF (env, peer_obj); - g_assert (peer_objGlobPtr); + gtk_tree_model_get (model, &iter, 0, &selected, -1); - ie->peer_obj = *peer_objGlobPtr; - ie->label = strdup (label); + gdk_threads_leave (); - g_signal_connect_data (G_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (item_activate), ie, - (GClosureNotify) item_removed, 0); + label = (*gdk_env)->NewStringUTF (gdk_env, selected); + (*gdk_env)->CallVoidMethod (gdk_env, peer, + choicePostItemEventID, + label, + (jint) AWT_ITEM_SELECTED); + gdk_threads_enter (); + } } diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c index 6bc24872dfa..8aaf0d26282 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c @@ -472,6 +472,63 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor gdk_threads_leave (); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent + (JNIEnv *env, jobject obj, jobject parent) +{ + void *ptr; + void *parent_ptr; + GtkWidget *widget; + GtkWidget *parent_widget; + + ptr = NSA_GET_PTR (env, obj); + parent_ptr = NSA_GET_PTR (env, parent); + + gdk_threads_enter (); + + widget = GTK_WIDGET (ptr); + parent_widget = GTK_WIDGET (parent_ptr); + + if (GTK_IS_WINDOW (parent_widget)) + { + GList *children = gtk_container_children + (GTK_CONTAINER (GTK_BIN (parent_widget)->child)); + + if (GTK_IS_MENU_BAR (children->data)) + gtk_layout_put (GTK_LAYOUT (children->next->data), widget, 0, 0); + else + gtk_layout_put (GTK_LAYOUT (children->data), widget, 0, 0); + } + else + if (GTK_IS_SCROLLED_WINDOW (parent_widget)) + { + gtk_scrolled_window_add_with_viewport + (GTK_SCROLLED_WINDOW (parent_widget), widget); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget->parent), + GTK_SHADOW_NONE); + + } + else + gtk_layout_put (GTK_LAYOUT (parent_widget), widget, 0, 0); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetSensitive + (JNIEnv *env, jobject obj, jboolean sensitive) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_widget_set_sensitive (GTK_WIDGET (ptr), sensitive); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus (JNIEnv *env, jobject obj) @@ -525,11 +582,11 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent event->key.send_event = 0; event->key.time = (guint32) when; - if (mods & AWT_SHIFT_MASK) + if (mods & AWT_SHIFT_DOWN_MASK) event->key.state |= GDK_SHIFT_MASK; - if (mods & AWT_CTRL_MASK) + if (mods & AWT_CTRL_DOWN_MASK) event->key.state |= GDK_CONTROL_MASK; - if (mods & AWT_ALT_MASK) + if (mods & AWT_ALT_DOWN_MASK) event->key.state |= GDK_MOD1_MASK; /* This hack is needed because the AWT has no notion of num lock. @@ -680,19 +737,33 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions gdk_threads_enter (); - /* Save the widget's current size request. */ - gtk_widget_size_request (GTK_WIDGET (ptr), ¤t_req); + /* Widgets that extend GtkWindow such as GtkFileChooserDialog may have + a default size. These values seem more useful then the natural + requisition values, particularly for GtkFileChooserDialog. */ + if (GTK_IS_WINDOW (ptr)) + { + gint width, height; + gtk_window_get_default_size (GTK_WINDOW (ptr), &width, &height); - /* Get the widget's "natural" size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); - gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); + dims[0] = width; + dims[1] = height; + } + else + { + /* Save the widget's current size request. */ + gtk_widget_size_request (GTK_WIDGET (ptr), ¤t_req); + + /* Get the widget's "natural" size request. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); + gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); - /* Reset the widget's size request. */ - gtk_widget_set_size_request (GTK_WIDGET (ptr), - current_req.width, current_req.height); + /* Reset the widget's size request. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), + current_req.width, current_req.height); - dims[0] = natural_req.width; - dims[1] = natural_req.height; + dims[0] = natural_req.width; + dims[1] = natural_req.height; + } gdk_threads_leave (); @@ -911,45 +982,6 @@ find_gtk_layout (GtkWidget *parent) return NULL; } -#define WIDGET_CLASS(w) GTK_WIDGET_CLASS (GTK_OBJECT (w)->klass) - -void -set_parent (GtkWidget *widget, GtkContainer *parent) -{ - if (GTK_IS_WINDOW (parent)) - { - GList *children = gtk_container_children - (GTK_CONTAINER (GTK_BIN (parent)->child)); - - if (GTK_IS_MENU_BAR (children->data)) - gtk_layout_put (GTK_LAYOUT (children->next->data), widget, 0, 0); - else /* GTK_IS_LAYOUT (children->data) */ - gtk_layout_put (GTK_LAYOUT (children->data), widget, 0, 0); - } - else - if (GTK_IS_SCROLLED_WINDOW (parent)) - { -/* if (WIDGET_CLASS (widget)->set_scroll_adjustments_signal) */ -/* gtk_container_add (GTK_CONTAINER (parent), widget); */ -/* else */ -/* { */ - gtk_scrolled_window_add_with_viewport - (GTK_SCROLLED_WINDOW (parent), widget); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget->parent), - GTK_SHADOW_NONE); -/* } */ - - } -/* gtk_layout_put */ -/* (GTK_LAYOUT (GTK_BIN (parent)->child), widget, 0, 0); */ - -/* if (GTK_IS_SCROLLED_WINDOW (parent)) */ -/* gtk_layout_put */ -/* (GTK_LAYOUT (GTK_BIN (GTK_BIN (parent)->child)->child), widget, 0, 0); */ - else - gtk_layout_put (GTK_LAYOUT (parent), widget, 0, 0); -} - JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled (JNIEnv *env, jobject obj) @@ -981,105 +1013,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_modalHasGrab return retval; } -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_String_2 - (JNIEnv *env, jobject obj, jstring jname, jstring jvalue) -{ - const char *name; - const char *value; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - value = (*env)->GetStringUTFChars (env, jvalue, NULL); - - gdk_threads_enter(); - g_object_set(ptr, name, value, NULL); - gdk_threads_leave(); - - (*env)->ReleaseStringUTFChars (env, jname, name); - (*env)->ReleaseStringUTFChars (env, jvalue, value); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Z - (JNIEnv *env, jobject obj, jstring jname, jboolean value) -{ - const char *name; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - - name = (*env)->GetStringUTFChars (env, jname, NULL); - - gdk_threads_enter(); - g_object_set(ptr, name, value, NULL); - gdk_threads_leave(); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2I - (JNIEnv *env, jobject obj, jstring jname, jint value) -{ - const char *name; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - - gdk_threads_enter(); - g_object_set(ptr, name, value, NULL); - gdk_threads_leave(); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2F - (JNIEnv *env, jobject obj, jstring jname, jfloat value) -{ - const char *name; - void *ptr; - - ptr = NSA_GET_PTR (env, obj); - name = (*env)->GetStringUTFChars (env, jname, NULL); - - gdk_threads_enter(); - g_object_set(ptr, name, value, NULL); - gdk_threads_leave(); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - -JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkComponentPeer_set__Ljava_lang_String_2Ljava_lang_Object_2 - (JNIEnv *env, jobject obj1, jstring jname, jobject obj2) -{ - const char *name; - void *ptr1, *ptr2; - - ptr1 = NSA_GET_PTR (env, obj1); - ptr2 = NSA_GET_PTR (env, obj2); - - name = (*env)->GetStringUTFChars (env, jname, NULL); - - /* special case to catch where we need to set the parent */ - if (!strcmp (name, "parent")) - { - gdk_threads_enter (); - set_parent (GTK_WIDGET (ptr1), GTK_CONTAINER (ptr2)); - gdk_threads_leave (); - - (*env)->ReleaseStringUTFChars (env, jname, name); - return; - } - - gdk_threads_enter(); - g_object_set(ptr1, name, ptr2, NULL); - gdk_threads_leave(); - - (*env)->ReleaseStringUTFChars (env, jname, name); -} - static gboolean filter_expose_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) { @@ -1111,6 +1044,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilt GList *children; void *ptr = NSA_GET_PTR (env, obj); jobject *gref = NSA_GET_GLOBAL_REF (env, obj); + gulong hid; g_assert (gref); @@ -1144,10 +1078,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilt { filterobj = GTK_OBJECT(ptr); } - - gulong hid = g_signal_handler_find(filterobj, - G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, *pre_event_handler, NULL); + hid = g_signal_handler_find(filterobj, + G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, *pre_event_handler, NULL); if (hid > 0) { g_signal_handler_block(filterobj, hid); @@ -1166,6 +1099,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeF GList *children; void *ptr = NSA_GET_PTR (env, obj); jobject *gref = NSA_GET_GLOBAL_REF (env, obj); + gulong hid; g_assert (gref); @@ -1202,9 +1136,9 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeF g_signal_handlers_disconnect_by_func (filterobj, *filter_expose_event_handler, *gref); - gulong hid = g_signal_handler_find(filterobj, - G_SIGNAL_MATCH_FUNC, - 0, 0, NULL, *pre_event_handler, NULL); + hid = g_signal_handler_find(filterobj, + G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, *pre_event_handler, NULL); if (hid > 0) { g_signal_handler_unblock(filterobj, hid); diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c index 8fb619e2563..7cf405df902 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c @@ -58,11 +58,11 @@ button_to_awt_mods (int button) switch (button) { case 1: - return AWT_BUTTON1_MASK; + return AWT_BUTTON1_DOWN_MASK; case 2: - return AWT_BUTTON2_MASK; + return AWT_BUTTON2_DOWN_MASK; case 3: - return AWT_BUTTON3_MASK; + return AWT_BUTTON3_DOWN_MASK; } return 0; @@ -74,11 +74,11 @@ state_to_awt_mods (guint state) jint result = 0; if (state & GDK_SHIFT_MASK) - result |= AWT_SHIFT_MASK; + result |= AWT_SHIFT_DOWN_MASK; if (state & GDK_CONTROL_MASK) - result |= AWT_CTRL_MASK; + result |= AWT_CTRL_DOWN_MASK; if (state & GDK_MOD1_MASK) - result |= AWT_ALT_MASK; + result |= AWT_ALT_DOWN_MASK; return result; } @@ -89,17 +89,17 @@ state_to_awt_mods_with_button_states (guint state) jint result = 0; if (state & GDK_SHIFT_MASK) - result |= AWT_SHIFT_MASK; + result |= AWT_SHIFT_DOWN_MASK; if (state & GDK_CONTROL_MASK) - result |= AWT_CTRL_MASK; + result |= AWT_CTRL_DOWN_MASK; if (state & GDK_MOD1_MASK) - result |= AWT_ALT_MASK; + result |= AWT_ALT_DOWN_MASK; if (state & GDK_BUTTON1_MASK) - result |= AWT_BUTTON1_MASK; + result |= AWT_BUTTON1_DOWN_MASK; if (state & GDK_BUTTON2_MASK) - result |= AWT_BUTTON2_MASK; + result |= AWT_BUTTON2_DOWN_MASK; if (state & GDK_BUTTON3_MASK) - result |= AWT_BUTTON3_MASK; + result |= AWT_BUTTON3_DOWN_MASK; return result; } @@ -124,29 +124,29 @@ keyevent_state_to_awt_mods (GdkEvent *event) if (event->key.keyval == GDK_Shift_L || event->key.keyval == GDK_Shift_R) - result |= AWT_SHIFT_MASK; + result |= AWT_SHIFT_DOWN_MASK; else { if (state & GDK_SHIFT_MASK) - result |= AWT_SHIFT_MASK; + result |= AWT_SHIFT_DOWN_MASK; } if (event->key.keyval == GDK_Control_L || event->key.keyval == GDK_Control_R) - result |= AWT_CTRL_MASK; + result |= AWT_CTRL_DOWN_MASK; else { if (state & GDK_CONTROL_MASK) - result |= AWT_CTRL_MASK; + result |= AWT_CTRL_DOWN_MASK; } if (event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R) - result |= AWT_ALT_MASK; + result |= AWT_ALT_DOWN_MASK; else { if (state & GDK_MOD1_MASK) - result |= AWT_ALT_MASK; + result |= AWT_ALT_DOWN_MASK; } } else if (event->type == GDK_KEY_RELEASE) @@ -157,20 +157,20 @@ keyevent_state_to_awt_mods (GdkEvent *event) && event->key.keyval != GDK_Shift_R) { if (state & GDK_SHIFT_MASK) - result |= AWT_SHIFT_MASK; + result |= AWT_SHIFT_DOWN_MASK; } if (event->key.keyval != GDK_Control_L && event->key.keyval != GDK_Control_R) { if (state & GDK_CONTROL_MASK) - result |= AWT_CTRL_MASK; + result |= AWT_CTRL_DOWN_MASK; } if (event->key.keyval != GDK_Alt_L && event->key.keyval != GDK_Alt_R) { if (state & GDK_MOD1_MASK) - result |= AWT_ALT_MASK; + result |= AWT_ALT_DOWN_MASK; } } @@ -885,8 +885,8 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) postMouseEventID, AWT_MOUSE_PRESSED, (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), + state_to_awt_mods (event->button.state) + | button_to_awt_mods (event->button.button), (jint)event->button.x, (jint)event->button.y, click_count, @@ -902,8 +902,8 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) postMouseEventID, AWT_MOUSE_RELEASED, (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), + state_to_awt_mods (event->button.state) + | button_to_awt_mods (event->button.button), (jint)event->button.x, (jint)event->button.y, click_count, @@ -923,8 +923,8 @@ pre_event_handler (GtkWidget *widget, GdkEvent *event, jobject peer) postMouseEventID, AWT_MOUSE_CLICKED, (jlong)event->button.time, - state_to_awt_mods (event->button.state) | - button_to_awt_mods (event->button.button), + state_to_awt_mods (event->button.state) + | button_to_awt_mods (event->button.button), (jint)event->button.x, (jint)event->button.y, click_count, diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c index 95bec4a10be..594fcce4165 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c @@ -151,6 +151,7 @@ gboolean filenameFilterCallback (const GtkFileFilterInfo *filter_info, jclass cx; jmethodID id; jstring *filename; + gboolean accepted; cx = (*gdk_env)->GetObjectClass (gdk_env, (jobject) obj); id = (*gdk_env)->GetMethodID (gdk_env, cx, "filenameFilterCallback", @@ -159,7 +160,7 @@ gboolean filenameFilterCallback (const GtkFileFilterInfo *filter_info, filename = (*gdk_env)->NewStringUTF(gdk_env, filter_info->filename); gdk_threads_leave(); - gboolean accepted = (*gdk_env)->CallBooleanMethod(gdk_env, obj, id, filename); + accepted = (*gdk_env)->CallBooleanMethod(gdk_env, obj, id, filename); gdk_threads_enter(); return accepted; diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c index a9da539f223..99107a1282c 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c @@ -63,12 +63,10 @@ jmethodID postWindowEventID; JNIEnv *gdk_env; -#ifdef PORTABLE_NATIVE_SYNC -JavaVM *gdk_vm; -#endif - GtkWindowGroup *global_gtk_window_group; +static void init_glib_threads(JNIEnv *, jint); + double dpi_conversion_factor; static void init_dpi_conversion_factor (); @@ -78,10 +76,17 @@ static void dpi_changed_cb (GtkSettings *settings, /* * Call gtk_init. It is very important that this happen before any other * gtk calls. + * + * The portableNativeSync argument may have the values: + * 1 if the Java property gnu.classpath.awt.gtk.portable.native.sync + * is set to "true". + * 0 if it is set to "false" + * -1 if unset. */ JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) +Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz, + jint portableNativeSync) { int argc = 1; char **argv; @@ -91,23 +96,22 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) gtkmenuitempeer, gtktextcomponentpeer, window; NSA_INIT (env, clazz); + gdk_env = env; /* GTK requires a program's argc and argv variables, and requires that they - be valid. */ - - argv = (char **) malloc (sizeof (char *) * 2); - argv[0] = ""; + be valid. Set it up. */ + argv = (char **) g_malloc (sizeof (char *) * 2); + argv[0] = (char *) g_malloc(1); +#if 1 + strcpy(argv[0], ""); +#else /* The following is a more efficient alternative, but less intuitively + * expresses what we are trying to do. This code is only run once, so + * I'm going for intuitive. */ + argv[0][0] = '\0'; +#endif argv[1] = NULL; - /* until we have JDK 1.2 JNI, assume we have a VM with threads that - match what GLIB was compiled for */ -#ifdef PORTABLE_NATIVE_SYNC - (*env)->GetJavaVM( env, &gdk_vm ); - g_thread_init ( &g_thread_jni_functions ); - printf("called gthread init\n"); -#else - g_thread_init ( NULL ); -#endif + init_glib_threads(env, portableNativeSync); /* From GDK 2.0 onwards we have to explicitly call gdk_threads_init */ gdk_threads_init(); @@ -122,21 +126,19 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) we're shutting down. */ atexit (gdk_threads_enter); - gdk_env = env; gdk_event_handler_set ((GdkEventFunc)awt_event_handler, NULL, NULL); if ((homedir = getenv ("HOME"))) { - rcpath = (char *) malloc (strlen (homedir) + strlen (RC_FILE) + 2); + rcpath = (char *) g_malloc (strlen (homedir) + strlen (RC_FILE) + 2); sprintf (rcpath, "%s/%s", homedir, RC_FILE); } gtk_rc_parse ((rcpath) ? rcpath : RC_FILE); - if (rcpath) - free (rcpath); - - free (argv); + g_free (rcpath); + g_free (argv[0]); + g_free (argv); /* setup cached IDs for posting GTK events to Java */ /* gtkgenericpeer = (*env)->FindClass (env, */ @@ -204,6 +206,37 @@ Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit (JNIEnv *env, jclass clazz) init_dpi_conversion_factor (); } + +/** Initialize GLIB's threads properly, based on the value of the + gnu.classpath.awt.gtk.portable.native.sync Java system property. If + that's unset, use the PORTABLE_NATIVE_SYNC config.h macro. (TODO: + In some release following 0.10, that config.h macro will go away.) + */ +static void +init_glib_threads(JNIEnv *env, jint portableNativeSync) +{ + if (portableNativeSync < 0) + { +#ifdef PORTABLE_NATIVE_SYNC /* Default value, if not set by the Java system + property */ + portableNativeSync = 1; +#else + portableNativeSync = 0; +#endif + } + + (*env)->GetJavaVM( env, &the_vm ); + if (portableNativeSync) + g_thread_init ( &portable_native_sync_jni_functions ); + else + g_thread_init ( NULL ); + + /* Debugging progress message; uncomment if needed: */ + /* printf("called gthread init\n"); */ +} + + + /* * Run gtk_main and block. */ diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c index 8034f647300..53c7351e6ec 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c @@ -70,6 +70,29 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_addMenu gdk_threads_leave (); } +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_nativeSetHelpMenu + (JNIEnv *env, jobject obj, jobject menupeer) +{ + static void *helpmenu; + void *mbar, *menu; + GList *list; + + mbar = NSA_GET_PTR (env, obj); + menu = NSA_GET_PTR (env, menupeer); + + gdk_threads_enter (); + if (helpmenu != NULL) + { + list = gtk_container_children (GTK_CONTAINER (mbar)); + while (list != NULL && list->data != helpmenu) + list = list->next; + if (list != NULL && list->data == helpmenu) + gtk_container_remove (GTK_CONTAINER (mbar), GTK_WIDGET (list->data)); + } + helpmenu = menu; + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuBarPeer_delMenu (JNIEnv *env, jobject obj, jint index) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c index 70fc8095519..5d5de6780a0 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c @@ -86,6 +86,18 @@ Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_connectSignals gdk_threads_leave (); } +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setEnabled + (JNIEnv *env, jobject obj, jboolean enabled) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + gtk_widget_set_sensitive (GTK_WIDGET (ptr), enabled); + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuItemPeer_setLabel (JNIEnv *env, jobject obj, jstring label) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c index 0bb0ec52567..1ffe61b0c52 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c @@ -39,20 +39,6 @@ exception statement from your version. */ #include "gtkpeer.h" #include "gnu_java_awt_peer_gtk_GtkMenuPeer.h" -static void -accel_attach (GtkMenuItem *menu_item, - gpointer *user_data __attribute__((unused))) -{ - GtkAccelGroup *accel; - - accel = gtk_menu_get_accel_group (GTK_MENU (menu_item->submenu)); - /* FIXME: update this to use GTK-2.4 GtkActions. */ -#if 0 - _gtk_accel_group_attach (accel, - G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET(menu_item)))); -#endif -} - JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup (JNIEnv *env, jobject obj, jobject parent) { @@ -65,14 +51,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_setupAccelGroup { gtk_menu_set_accel_group (GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu), gtk_accel_group_new ()); - - if (GTK_WIDGET_REALIZED (GTK_WIDGET (ptr1))) - accel_attach (GTK_MENU_ITEM (ptr1), NULL); - else - g_signal_connect (G_OBJECT (ptr1), - "realize", - GTK_SIGNAL_FUNC (accel_attach), - NULL); } else { @@ -128,6 +106,24 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_create (*env)->ReleaseStringUTFChars (env, label, str); } +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addTearOff + (JNIEnv *env, jobject obj) +{ + void *ptr1; + GtkWidget *menu, *item; + + ptr1 = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (ptr1)); + item = gtk_tearoff_menu_item_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + gtk_widget_show (item); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkMenuPeer_addItem (JNIEnv *env, jobject obj, jobject menuitempeer, jint key, jboolean shift) { diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c index 2d62c33a4d7..771f2b81d75 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c @@ -151,7 +151,6 @@ Java_gnu_java_awt_peer_gtk_GtkTextComponentPeer_setCaretPosition GtkWidget *text = NULL; GtkTextBuffer *buf; GtkTextIter iter; - GtkTextMark *mark; GtkTextMark *oldmark; GtkTextIter olditer; int oldpos; diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c index 5bea49a3f3c..2a6666a0d83 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c @@ -62,6 +62,47 @@ Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_create NSA_SET_PTR (env, obj, entry); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetSetBackground + (JNIEnv *env, jobject obj, jint red, jint green, jint blue) +{ + GdkColor color; + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + color.red = (red / 255.0) * 65535; + color.green = (green / 255.0) * 65535; + color.blue = (blue / 255.0) * 65535; + + gdk_threads_enter (); + + gtk_widget_modify_base (GTK_WIDGET (ptr), GTK_STATE_NORMAL, &color); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkWidgetSetForeground + (JNIEnv *env, jobject obj, jint red, jint green, jint blue) +{ + GdkColor color; + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + color.red = (red / 255.0) * 65535; + color.green = (green / 255.0) * 65535; + color.blue = (blue / 255.0) * 65535; + + gdk_threads_enter (); + + gtk_widget_modify_text (GTK_WIDGET (ptr), GTK_STATE_NORMAL, &color); + gtk_widget_modify_base (GTK_WIDGET (ptr), GTK_STATE_SELECTED, &color); + + gdk_threads_leave (); +} + JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GtkTextFieldPeer_gtkEntryGetBorderWidth (JNIEnv *env, jobject obj) diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c index 4d11e6201bc..508893168b1 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c @@ -104,7 +104,6 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create insets = (*env)->GetIntArrayElements (env, jinsets, 0); insets[0] = insets[1] = insets[2] = insets[3] = 0; - /* Create global reference and save it for future use */ NSA_SET_GLOBAL_REF (env, obj); gdk_threads_enter (); @@ -162,6 +161,56 @@ Java_gnu_java_awt_peer_gtk_GtkWindowPeer_create NSA_SET_PTR (env, obj, window_widget); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetTitle + (JNIEnv *env, jobject obj, jstring title) +{ + const char *c_title; + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + c_title = (*env)->GetStringUTFChars (env, title, NULL); + + gdk_threads_enter (); + + gtk_window_set_title (GTK_WINDOW (ptr), c_title); + + gdk_threads_leave (); + + (*env)->ReleaseStringUTFChars (env, title, c_title); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetResizable + (JNIEnv *env, jobject obj, jboolean resizable) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_window_set_policy (GTK_WINDOW (ptr), resizable, resizable, FALSE); + + gdk_threads_leave (); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkWindowPeer_gtkWindowSetModal + (JNIEnv *env, jobject obj, jboolean modal) +{ + void *ptr; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + gtk_window_set_modal (GTK_WINDOW (ptr), modal); + + gdk_threads_leave (); +} + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetVisible (JNIEnv *env, jobject obj, jboolean visible) @@ -486,6 +535,72 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkLayoutSetVisible gdk_threads_leave (); } +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromDecoder + (JNIEnv *env, jobject obj, jobject decoder) +{ + void *ptr; + GdkPixbufLoader *loader = NULL; + GdkPixbuf *pixbuf = NULL; + + ptr = NSA_GET_PTR (env, obj); + + loader = NSA_GET_PB_PTR (env, decoder); + g_assert (loader != NULL); + + gdk_threads_enter (); + + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + g_assert (pixbuf != NULL); + + gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf); + + gdk_threads_leave (); +} + +void free_pixbuf_data (guchar *pixels, gpointer data __attribute__((unused))) +{ + free(pixels); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromData + (JNIEnv *env, jobject obj, jintArray pixelArray, jint width, jint height) +{ + void *ptr; + GdkPixbuf *pixbuf; + jint *pixels; + int pixels_length, i; + guchar *data; + + ptr = NSA_GET_PTR (env, obj); + + pixels = (*env)->GetIntArrayElements (env, pixelArray, 0); + pixels_length = (*env)->GetArrayLength (env, pixelArray); + + data = malloc (sizeof (guchar) * pixels_length); + for (i = 0; i < pixels_length; i++) + data[i] = (guchar) pixels[i]; + + gdk_threads_enter (); + + pixbuf = gdk_pixbuf_new_from_data (data, + GDK_COLORSPACE_RGB, + TRUE, + 8, + width, + height, + width*4, + free_pixbuf_data, + NULL); + + gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf); + + gdk_threads_leave (); + + (*env)->ReleaseIntArrayElements(env, pixelArray, pixels, 0); +} + static void window_get_frame_extents (GtkWidget *window, int *top, int *left, int *bottom, int *right) diff --git a/libjava/jni/gtk-peer/gthread-jni.c b/libjava/jni/gtk-peer/gthread-jni.c index 3dd5596b4bc..ee79424475c 100644 --- a/libjava/jni/gtk-peer/gthread-jni.c +++ b/libjava/jni/gtk-peer/gthread-jni.c @@ -40,142 +40,1166 @@ exception statement from your version. */ /************************************************************************/ /* - * Julian Dolby (dolby@us.ibm.com) - * February 7, 2003 + * @author Julian Dolby (dolby@us.ibm.com) + * @date February 7, 2003 implemented for GLIB v.1 + * + * + * @author Steven Augart + * , + * @date April 30, 2004 -- May 10 2004: Support new functions for Glib v.2, + * fix cond_wait to free and re-acquire the mutex, + * replaced trylock stub implementation with a full one. * * This code implements the GThreadFunctions interface for GLIB using * Java threading primitives. All of the locking and conditional variable * functionality required by GThreadFunctions is implemented using the * monitor and wait/notify functionality of Java objects. The thread- - * local fucntionality uses the java.lang.ThreadLocal class. + * local functionality uses the java.lang.ThreadLocal class. + * + * Classpath's AWT support uses GTK+ peers. GTK+ uses GLIB. GLIB by default + * uses the platform's native threading model -- pthreads in most cases. If + * the Java runtime doesn't use the native threading model, then it needs this + * code in order to use Classpath's (GTK+-based) AWT routines. * - * This code is designed to be portable in that it makes no assumptions + * This code should be portable; I believe it makes no assumptions * about the underlying VM beyond that it implements the JNI functionality * that this code uses. * - * The one piece that does not really work is trylock for mutexes. The - * Java locking model does not include such functionality, and I do not - * see how to implement it without knowing something about how the VM - * implements locking. + * Currently, use of this code is governed by the configuration option + * --enable-portable-native-sync. We will soon add a VM hook so the VM can + * select which threading model it wants to use at run time; at that point, + * the configuration option will go away. + * + * The code in this file uses only JNI 1.1, except for one JNI 1.2 function: + * GetEnv, in the JNI Invocation API. (There seems to be no way around using + * GetEnv). + * + * ACKNOWLEDGEMENT: + * + * I would like to thank Mark Wielaard for his kindness in spending at least + * six hours of his own time in reviewing this code and correcting my GNU + * coding and commenting style. --Steve Augart + * * * NOTES: * - * I have tested it only on JikesRVM---the CVS head as of early February - * 2003. + * This code has been tested with Jikes RVM and with Kaffe. * - * Currently, use of this code is governed by the configuration option - * --enable-portable-native-sync + * This code should have proper automated unit tests. I manually tested it + * by running an application that uses AWT. --Steven Augart + * + * MINOR NIT: * + * - Using a jboolean in the arglist to "throw()" and "rethrow()" + * triggers many warnings from GCC's -Wconversion operation, because that + * is not the same as the conversion (upcast to an int) that would occur in + * the absence of a prototype. + * + * It would be very slightly more efficient to just pass the jboolean, but + * is not worth the clutter of messages. The right solution would be to + * turn off the -Wconversion warning for just this file, *except* that + * -Wconversion also warns you against constructs such as: + * unsigned u = -1; + * and that is a useful warning. So I went from a "jboolean" to a + * "gboolean" (-Wconversion is not enabled by default for GNU Classpath, + * but it is in my own CFLAGS, which, for gcc 3.3.3, read: -pipe -ggdb3 -W + * -Wall -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual + * -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations + * -fkeep-static-consts -fkeep-inline-functions -Wundef -Wwrite-strings + * -Wno-aggregate-return -Wmissing-noreturn -Wnested-externs -Wtrigraphs + * -Wconversion -Wsign-compare -Wno-float-equal -Wmissing-format-attribute + * -Wno-unreachable-code -Wdisabled-optimization ) */ +#include + +/************************************************************************/ +/* Configuration */ +/************************************************************************/ + +/** Tracing and Reporting **/ +#define TRACE_API_CALLS 0 /* announce entry and exit into each method, + by printing to stderr. */ + +#define TRACE_MONITORS 0 /* Every enterMonitor() and exitMonitor() goes + to stderr. */ + +/** Trouble handling. There is a discussion below of this. **/ +#define EXPLAIN_TROUBLE 1 /* Describe any unexpected trouble that + happens. This is a superset + of EXPLAIN_BROKEN, and if set trumps an + unset EXPLAIN_BROKEN. It is not a strict + superset, since at the moment there is no + TROUBLE that is not also BROKEN. + + Use criticalMsg() to describe the problem. + */ + +#define EXPLAIN_BROKEN 1 /* Describe trouble that is serious enough to + be BROKEN. (Right now all trouble is at + least BROKEN.) */ + +/* There is no EXPLAIN_BADLY_BROKEN definition. We always explain + BADLY_BROKEN trouble, since there is no other way to report it. */ + + +/** Error Handling **/ +#define DIE_IF_BROKEN 1 /* Dies if serious trouble happens. There is + really no non-serious trouble, except + possibly problems that arise during + pthread_create, which are reported by a + GError. + + If you do not set DIE_IF_BROKEN, then + trouble will raise a Java RuntimeException. + We probably do want to die right away, + since anything that's BROKEN really + indicates a programming error or a + system-wide error, and that's what the glib + documentation says you should do in case of + that kind of error in a glib-style + function. But it does work to turn this + off. */ + +#if DIE_IF_BROKEN +#define DIE_IF_BADLY_BROKEN 1 /* DIE_IF_BROKEN implies DIE_IF_BADLY_BROKEN */ +#else +#define DIE_IF_BADLY_BROKEN 1 /* Die if the system is badly broken -- + that is, if we have further trouble while + attempting to throw an exception + upwards, or if we are unable to generate + one of the classes we'll need in order to + throw wrapped exceptions upward. + + If unset, we will print a warning message, + and limp along anyway. Not that the system + is likely to work. */ +#endif + +/** Performance tuning parameters **/ + +#define ENABLE_EXPENSIVE_ASSERTIONS 0 /* Enable expensive assertions? */ + +#define DELETE_LOCAL_REFS 1 /* Whether to delete local references. + + JNI only guarantees that there wil be 16 + available. (Jikes RVM provides an number + only limited by VM memory.) + + Jikes RVM will probably perform faster if + this is turned off, but other VMs may need + this to be turned on in order to perform at + all, or might need it if things change. + + Remember, we don't know how many of those + local refs might have already been used up + by higher layers of JNI code that end up + calling g_thread_self(), + g_thread_set_private(), and so on. + + We set this to 1 for GNU Classpath, since + one of our principles is "always go for the + most robust implementation" */ + +#define HAVE_JNI_VERSION_1_2 0 /* Assume we don't. We could + dynamically check for this. We will + assume JNI 1.2 in later versions of + Classpath. + + As it stands, the code in this file + already needs one JNI 1.2 function: + GetEnv, in the JNI Invocation API. + + TODO This code hasn't been tested yet. + And really hasn't been implemented yet. + */ /************************************************************************/ /* Global data */ /************************************************************************/ +#if defined HAVE_STDINT_H +#include /* provides intptr_t */ +#elif defined HAVE_INTTYPES_H +#include +#endif +#include /* snprintf */ +#include /* va_list */ #include "gthread-jni.h" +#include /* assert() */ + +/* For Java thread priority constants. */ +#include + +/* Since not all JNI header generators actually define constants we + define them here explicitly. */ +#ifndef gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MIN_PRIORITY +#define gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MIN_PRIORITY 1 +#endif +#ifndef gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_NORM_PRIORITY +#define gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_NORM_PRIORITY 5 +#endif +#ifndef gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MAX_PRIORITY +#define gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MAX_PRIORITY 10 +#endif + +/* The VM handle. This is set in + Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit */ +JavaVM *the_vm; + +/* Unions used for type punning. */ +union env_union +{ + void **void_env; + JNIEnv **jni_env; +}; + +union func_union +{ + void *void_func; + GThreadFunc g_func; +}; + +/* Forward Declarations for Functions */ +static int threadObj_set_priority (JNIEnv * env, jobject threadObj, + GThreadPriority gpriority); +static void fatalMsg (const char fmt[], ...) + __attribute__ ((format (printf, 1, 2))) + __attribute__ ((noreturn)); + +static void criticalMsg (const char fmt[], ...) + __attribute__ ((format (printf, 1, 2))); -/* The VM handle. This is set in GtkToolkitMain.gtkInit */ -JavaVM *gdk_vm; +static void tracing (const char fmt[], ...) + __attribute__ ((format (printf, 1, 2))); +static jint javaPriorityLevel (GThreadPriority priority) + __attribute__ ((const)); /************************************************************************/ -/* Utilities to reflect exceptions back to the VM */ +/* Trouble-handling, including utilities to reflect exceptions */ +/* back to the VM. Also some status reporting. */ /************************************************************************/ -/* This function checks for a pending exception, and rethrows it with +/* How are we going to handle problems? + + There are several approaches: + + 1) Report them with the GError mechanism. + + (*thread_create)() is the only one of these functions that takes a + GError pointer. And the only G_THREAD error defined maps onto EAGAIN. + We don't have any errors in our (*thread_create)() implementation that + can be mapped to EAGAIN. So this idea is a non-starter. + + 2) Reflect the exception back to the VM, wrapped in a RuntimeException. + This will fail sometimes, if we're so broken (BADLY_BROKEN) that we + fail to throw the exception. + + 3) Abort execution. This is what the glib functions themselves do for + errors that they can't report via GError. + + Enable DIE_IF_BROKEN and/or DIE_IF_BADLY_BROKEN to + make this the default for BROKEN and/or BADLY_BROKEN trouble. + + 4) Display messages to stderr. We always do this for BADLY_BROKEN + trouble. The glib functions do that for errors they can't report via + GError. + + There are some complications. + + When I attempted to report a problem in g_thread_self() using g_critical (a + macro around g_log(), I found that g_log in turn looks for thread-private + data and calls g_thread_self() again. + + We got a segfault, probably due to stack overflow. So, this code doesn't + use the g_critical() and g_error() functions any more. Nor do we use + g_assert(); we use the C library's assert() instead. +*/ + + +#define WHERE __FILE__ ":" G_STRINGIFY(__LINE__) ": " + +/* This is portable to older compilers that lack variable-argument macros. + This used to be just g_critical(), but then we ran into the error reporting + problem discussed above. +*/ +static void +fatalMsg (const char fmt[], ...) +{ + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + fputs ("\nAborting execution\n", stderr); + abort (); +} + + +static void +criticalMsg (const char fmt[], ...) +{ + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + putc ('\n', stderr); +} + +/* Unlike the other two, this one does not append a newline. This is only + used if one of the TRACE_ macros is defined. */ +static void +tracing (const char fmt[], ...) +{ + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); +} + +#define assert_not_reached() \ + do \ + { \ + fputs(WHERE "You should never get here. Aborting execution.\n", \ + stderr); \ + abort(); \ + } \ + while(0) + + +#if DIE_IF_BADLY_BROKEN +#define BADLY_BROKEN fatalMsg +#else +#define BADLY_BROKEN criticalMsg +/* So, the user may still attempt to recover, even though we do not advise + this. */ +#endif + +/* I find it so depressing to have to use C without varargs macros. */ +#define BADLY_BROKEN_MSG WHERE "Something fundamental" \ + " to GNU Classpath's AWT JNI broke while we were trying to pass up a Java error message" + +#define BADLY_BROKEN0() \ + BADLY_BROKEN(BADLY_BROKEN_MSG); +#define BADLY_BROKEN1(msg) \ + BADLY_BROKEN(BADLY_BROKEN_MSG ": " msg) +#define BADLY_BROKEN2(msg, arg) \ + BADLY_BROKEN(BADLY_BROKEN_MSG ": " msg, arg) +#define BADLY_BROKEN3(msg, arg, arg2) \ + BADLY_BROKEN(BADLY_BROKEN_MSG ": " msg, arg1, arg2) +#define BADLY_BROKEN4(msg, arg, arg2, arg3) \ + BADLY_BROKEN(BADLY_BROKEN_MSG ": " msg, arg1, arg2, arg3) + +#define DELETE_LOCAL_REF(env, ref) \ + do \ + { \ + if ( DELETE_LOCAL_REFS ) \ + { \ + (*env)->DeleteLocalRef (env, ref); \ + (ref) = NULL; \ + } \ + } \ + while(0) + +/* Cached info for Exception-wrapping */ + +jclass runtimeException_class; /* java.lang.RuntimeException */ +jmethodID runtimeException_ctor; /* constructor for it */ + + +/* Throw a new RuntimeException. It may wrap around an existing exception. + 1 if we did rethrow, -1 if we had trouble while rethrowing. + isBroken is always true in this case. */ +static int +throw (JNIEnv * env, jthrowable cause, const char *message, + gboolean isBroken, const char *file, int line) +{ + jstring jmessage; + gboolean describedException = FALSE; /* Did we already describe the + exception to stderr or the + equivalent? */ + jthrowable wrapper; + + /* allocate local message in Java */ + const char fmt[] = "In AWT JNI, %s (at %s:%d)"; + size_t len = strlen (message) + strlen (file) + sizeof fmt + 25; + char *buf; + + if (EXPLAIN_TROUBLE || (isBroken && EXPLAIN_BROKEN)) + { + criticalMsg ("%s:%d: AWT JNI failure%s: %s\n", file, line, + isBroken ? " (BROKEN)" : "", message); + if (cause) + { + jthrowable currentException = (*env)->ExceptionOccurred (env); + + if (cause == currentException) + { + criticalMsg ("Description follows to System.err:"); + (*env)->ExceptionDescribe (env); + /* ExceptionDescribe has the side-effect of clearing the pending + exception; relaunch it. */ + describedException = TRUE; + + if ((*env)->Throw (env, cause)) + { + BADLY_BROKEN1 + ("Relaunching an exception with Throw failed."); + return -1; + } + } + else + { + DELETE_LOCAL_REF (env, currentException); + criticalMsg (WHERE + "currentException != cause; something else happened" + " while handling an exception."); + } + } + } /* if (EXPLAIN_TROUBLE) */ + + if (isBroken && DIE_IF_BROKEN) + fatalMsg ("%s:%d: Aborting execution; BROKEN: %s\n", file, line, message); + + if ((buf = malloc (len))) + { + memset (buf, 0, len); + snprintf (buf, len, fmt, message, file, line); + jmessage = (*env)->NewStringUTF (env, buf); + free (buf); + } + else + { + jmessage = NULL; + } + + /* Create the RuntimeException wrapper object and throw it. It is OK for + CAUSE to be NULL. */ + wrapper = (jthrowable) (*env)->NewObject + (env, runtimeException_class, runtimeException_ctor, jmessage, cause); + DELETE_LOCAL_REF (env, jmessage); + + if (!wrapper) + { + /* I think this should only happen: + - if there are bugs in my JNI code, or + - if the VM is broken, or + - if we run out of memory. + */ + if (EXPLAIN_TROUBLE) + { + criticalMsg (WHERE "GNU Classpath: JNI NewObject() could not create" + " a new java.lang.RuntimeException."); + criticalMsg ("We were trying to warn about the following" + " previous failure:"); + criticalMsg ("%s:%d: %s", file, line, message); + criticalMsg ("The latest (NewObject()) exception's description" + " follows, to System.err:"); + (*env)->ExceptionDescribe (env); + } + BADLY_BROKEN1 ("Failure of JNI NewObject()" + " to make a java.lang.RuntimeException"); + return -1; + } + + + /* throw it */ + if ((*env)->Throw (env, wrapper)) + { + /* Throw() should just never fail, unless we're in such severe trouble + that we might as well die. */ + BADLY_BROKEN1 + ("GNU Classpath: Failure of JNI Throw to report an Exception"); + return -1; + } + + DELETE_LOCAL_REF (env, wrapper); + return 1; +} + + + +/* Rethrow an exception we received, wrapping it with a RuntimeException. 1 + if we did rethrow, -1 if we had trouble while rethrowing. + CAUSE should be identical to the most recent exception that happened, so + that ExceptionDescribe will work. (Otherwise nix.) */ +static int +rethrow (JNIEnv * env, jthrowable cause, const char *message, + gboolean isBroken, const char *file, int line) +{ + assert (cause); + return throw (env, cause, message, isBroken, file, line); +} + + +/* This function checks for a pending exception, and rethrows it with * a wrapper RuntimeException to deal with possible type problems (in * case some calling piece of code does not expect the exception being * thrown) and to include the given extra message. + * + * Returns 0 if no problems found (so no exception thrown), 1 if we rethrew an + * exception. Returns -1 on failure. */ -static void maybe_rethrow(JNIEnv *gdk_env, char *message, char *file, int line) { - jthrowable cause; +static int +maybe_rethrow (JNIEnv * env, const char *message, gboolean isBroken, + const char *file, int line) +{ + jthrowable cause = (*env)->ExceptionOccurred (env); + int ret = 0; + + /* rethrow if an exception happened */ + if (cause) + { + ret = rethrow (env, cause, message, isBroken, file, line); + DELETE_LOCAL_REF (env, cause); + } + + return 0; +} + +/* MAYBE_TROUBLE() is used to include a source location in the exception + message. Once we have run maybe_rethrow, if there WAS trouble, + return TRUE, else FALSE. + + MAYBE_TROUBLE() is actually never used; all problems that throw exceptions + are BROKEN, at least. Nothing is recoverable :(. See the discussion of + possible errors at thread_create_jni_impl(). */ +#define MAYBE_TROUBLE(_env, _message) \ + maybe_rethrow(_env, _message, FALSE, __FILE__, __LINE__) + +/* MAYBE_TROUBLE(), but something would be BROKEN if it were true. */ +#define MAYBE_BROKEN(_env, _message) \ + maybe_rethrow(_env, _message, TRUE, __FILE__, __LINE__) + +/* Like MAYBE_TROUBLE(), TROUBLE() is never used. */ +#define TROUBLE(_env, _message) \ + rethrow(_env, (*env)->ExceptionOccurred (env), _message, FALSE, \ + __FILE__, __LINE__) + +#define BROKEN(_env, _message) \ + rethrow (_env, (*env)->ExceptionOccurred (env), _message, TRUE, \ + __FILE__, __LINE__) + +/* Like MAYBE_TROUBLE(), NEW_TROUBLE() is never used. */ +#define NEW_TROUBLE(_env, _message) \ + throw (_env, NULL, _message, FALSE, __FILE__, __LINE__) + +#define NEW_BROKEN(_env, _message) \ + throw (_env, NULL, _message, TRUE, __FILE__, __LINE__) + +/* Like MAYBE_TROUBLE(), RETHROW_CAUSE() is never used. */ +#define RETHROW_CAUSE(_env, _cause, _message) \ + rethrow (_env, _cause, _message, FALSE, __FILE__, __LINE__) + +#define BROKEN_CAUSE(_env, _cause, _message) \ + rethrow (_env, _cause, _message, TRUE, __FILE__, __LINE__) + +/* Macros to handle the possibility that someone might have called one of the + GThreadFunctions API functions with a Java exception pending. It is + generally discouraged to continue to use JNI after a Java exception has + been raised. Sun's JNI book advises that one trap JNI errors immediately + and not continue with an exception pending. + + These are #if'd out for these reasons: + + 1) They do not work in the C '89 subset that Classpath is currently + (2004 May 10) sticking to; HIDE_OLD_TROUBLE() includes a declaration + that should be in scope for the rest of the function, so it needs a + language version that lets you mix declarations and statements. (This + could be worked around if it were important.) + + 2) They chew up more time and resources. + + 3) There does not ever seem to be old trouble -- the assertion in + HIDE_OLD_TROUBLE never goes off. + + You will want to re-enable them if this code needs to be used in a context + where old exceptions might be pending when the GThread functions are + called. + + The implementations in this file are responsible for skipping around calls + to SHOW_OLD_TROUBLE() if they've raised exceptions during the call. So, if + we reach SHOW_OLD_TROUBLE, we are guaranteed that there are no exceptions + pending. */ +#if 1 +#define HIDE_OLD_TROUBLE(env) \ + assert ( NULL == (*env)->ExceptionOccurred (env) ) + +#define SHOW_OLD_TROUBLE() \ + assert ( NULL == (*env)->ExceptionOccurred (env) ) +#else /* 0 */ +#define HIDE_OLD_TROUBLE(env) \ + jthrowable savedTrouble = (*env)->ExceptionOccurred (env); \ + (*env)->ExceptionClear (env); + +#define SHOW_OLD_TROUBLE() do \ +{ \ + assert ( NULL == (*env)->ExceptionOccurred (env) ) \ + if (savedTrouble) \ + { \ + if ((*env)->Throw (env, savedTrouble)) \ + BADLY_BROKEN ("ReThrowing the savedTrouble failed"); \ + } \ + DELETE_LOCAL_REF (env, savedTrouble); \ +} while(0) + +#endif /* 0 */ + +/* Set up the cache of jclass and jmethodID primitives we need + in order to throw new exceptions and rethrow exceptions. We do this + independently of the other caching. We need to have this cache set up + first, so that we can then report errors properly. + + If any errors while setting up the error cache, the world is BADLY_BROKEN. + + May be called more than once. + + Returns -1 if the cache was not initialized properly, 1 if it was. +*/ +static int +setup_exception_cache (JNIEnv * env) +{ + static int exception_cache_initialized = 0; /* -1 for trouble, 1 for proper + init. */ + + jclass lcl_class; /* a class used for local refs */ + + if (exception_cache_initialized) + return exception_cache_initialized; + lcl_class = (*env)->FindClass (env, "java/lang/RuntimeException"); + if ( ! lcl_class ) + { + BADLY_BROKEN1 ("Broken Class library or VM?" + " Couldn't find java/lang/RuntimeException"); + return exception_cache_initialized = -1; + } + /* Pin it down. */ + runtimeException_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!runtimeException_class) + { + BADLY_BROKEN1 ("Serious trouble: could not turn" + " java.lang.RuntimeException into a global reference"); + return exception_cache_initialized = -1; + } + + runtimeException_ctor = + (*env)->GetMethodID (env, runtimeException_class, "", + "(Ljava/lang/String;Ljava/lang/Throwable;)V"); + if ( ! runtimeException_ctor ) + { + BADLY_BROKEN1 ("Serious trouble: classpath couldn't find a" + " two-arg constructor for java/lang/RuntimeException"); + return exception_cache_initialized = -1; + } + + return exception_cache_initialized = 1; +} + + +/**********************************************************/ +/***** The main cache *************************************/ +/**********************************************************/ + +/** This is a cache of all classes, methods, and field IDs that we use during + the run. We maintain a permanent global reference to each of the classes + we cache, since otherwise the (local) jclass that refers to that class + would go out of scope and possibly be reused in further calls. + + The permanent global reference also achieves the secondary goal of + protecting the validity of the methods and field IDs in case the classes + were otherwise unloaded and then later loaded again. Obviously, this will + never happen to classes such as java.lang.Thread and java.lang.Object, but + the primary reason for maintaining permanent global refs is sitll valid. + + The code in jnilink.c has a similar objective. TODO: Consider using that + code instead. + + --Steven Augart +*/ + +/* All of these are cached classes and method IDs: */ +/* java.lang.Object */ +static jclass obj_class; /* java.lang.Object */ +static jmethodID obj_ctor; /* no-arg Constructor for java.lang.Object */ +static jmethodID obj_notify_mth; /* java.lang.Object.notify() */ +static jmethodID obj_notifyall_mth; /* java.lang.Object.notifyall() */ +static jmethodID obj_wait_mth; /* java.lang.Object.wait() */ +static jmethodID obj_wait_nanotime_mth; /* java.lang.Object.wait(JI) */ + +/* GThreadMutex and its methods */ +static jclass mutex_class; +static jmethodID mutex_ctor; +static jfieldID mutex_lockForPotentialLockers_fld; +static jfieldID mutex_potentialLockers_fld; + +/* java.lang.Thread and its methods*/ +static jclass thread_class; /* java.lang.Thread */ +static jmethodID thread_current_mth; /* Thread.currentThread() */ +static jmethodID thread_equals_mth; /* Thread.equals() */ +static jmethodID thread_join_mth; /* Thread.join() */ +static jmethodID thread_setPriority_mth; /* Thread.setPriority() */ +static jmethodID thread_stop_mth; /* Thread.stop() */ +static jmethodID thread_yield_mth; /* Thread.yield() */ + +/* java.lang.ThreadLocal and its methods */ +static jclass threadlocal_class; /* java.lang.ThreadLocal */ +static jmethodID threadlocal_ctor; /* Its constructor */ +static jmethodID threadlocal_set_mth; /* ThreadLocal.set() */ +static jmethodID threadlocal_get_mth; /* ThreadLocal.get() */ + +/* java.lang.Long and its methods */ +static jclass long_class; /* java.lang.Long */ +static jmethodID long_ctor; /* constructor for it: (J) */ +static jmethodID long_longValue_mth; /* longValue()J */ + + +/* GThreadNativeMethodRunner */ +static jclass runner_class; +static jmethodID runner_ctor; +static jmethodID runner_threadToThreadID_mth; +static jmethodID runner_threadIDToThread_mth; +static jmethodID runner_deRegisterJoinable_mth; +static jmethodID runner_start_mth; /* Inherited Thread.start() */ + + +/* java.lang.InterruptedException */ +static jclass interrupted_exception_class; + + + + +/* Returns a negative value if there was trouble during initialization. + Returns a positive value of the cache was initialized correctly. + Never returns zero. */ +static int +setup_cache (JNIEnv * env) +{ + jclass lcl_class; + static int initialized = 0; /* 1 means initialized, 0 means uninitialized, + -1 means mis-initialized */ + + if (initialized) + return initialized; + + /* make sure we can report on trouble */ + if (setup_exception_cache (env) < 0) + return initialized = -1; + +#ifdef JNI_VERSION_1_2 + if (HAVE_JNI_VERSION_1_2) + assert ( ! (*env)->ExceptionCheck (env)); + else +#endif + assert ( ! (*env)->ExceptionOccurred (env)); + + /* java.lang.Object and its methods */ + lcl_class = (*env)->FindClass (env, "java/lang/Object"); + if (!lcl_class) + { + BROKEN (env, "cannot find java.lang.Object"); + return initialized = -1; + } + + /* Pin it down. */ + obj_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!obj_class) + { + BROKEN (env, "Cannot get a global reference to java.lang.Object"); + return initialized = -1; + } + + obj_ctor = (*env)->GetMethodID (env, obj_class, "", "()V"); + if (!obj_ctor) + { + BROKEN (env, "cannot find constructor for java.lang.Object"); + return initialized = -1; + } + + obj_notify_mth = (*env)->GetMethodID (env, obj_class, "notify", "()V"); + if ( ! obj_notify_mth ) + { + BROKEN (env, "cannot find java.lang.Object.notify()V"); + return initialized = -1; + } + + obj_notifyall_mth = + (*env)->GetMethodID (env, obj_class, "notifyAll", "()V"); + if ( ! obj_notifyall_mth) + { + BROKEN (env, "cannot find java.lang.Object.notifyall()V"); + return initialized = -1; + } + + obj_wait_mth = (*env)->GetMethodID (env, obj_class, "wait", "()V"); + if ( ! obj_wait_mth ) + { + BROKEN (env, "cannot find Object."); + return initialized = -1; + } + + obj_wait_nanotime_mth = + (*env)->GetMethodID (env, obj_class, "wait", "(JI)V"); + if ( ! obj_wait_nanotime_mth ) + { + BROKEN (env, "cannot find Object."); + return initialized = -1; + } + + /* GThreadMutex and its methods */ + lcl_class = (*env)->FindClass (env, "gnu/java/awt/peer/gtk/GThreadMutex"); + if ( ! lcl_class) + { + BROKEN (env, "cannot find gnu.java.awt.peer.gtk.GThreadMutex"); + return initialized = -1; + } + /* Pin it down. */ + mutex_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if ( ! mutex_class) + { + BROKEN (env, "Cannot get a global reference to GThreadMutex"); + return initialized = -1; + } + + mutex_ctor = (*env)->GetMethodID (env, mutex_class, "", "()V"); + if ( ! mutex_ctor) + { + BROKEN (env, "cannot find zero-arg constructor for GThreadMutex"); + return initialized = -1; + } + + mutex_potentialLockers_fld = (*env)->GetFieldID + (env, mutex_class, "potentialLockers", "I"); + if ( ! mutex_class ) + { + BROKEN (env, "cannot find GThreadMutex.potentialLockers"); + return initialized = -1; + } + + if (! (mutex_lockForPotentialLockers_fld = (*env)->GetFieldID + (env, mutex_class, "lockForPotentialLockers", "Ljava/lang/Object;"))) + { + BROKEN (env, "cannot find GThreadMutex.lockForPotentialLockers"); + return initialized = -1; + } + + + /* java.lang.Thread */ + if (! (lcl_class = (*env)->FindClass (env, "java/lang/Thread"))) + { + BROKEN (env, "cannot find java.lang.Thread"); + return initialized = -1; + } + + /* Pin it down. */ + thread_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!thread_class) + { + BROKEN (env, "Cannot get a global reference to java.lang.Thread"); + return initialized = -1; + } + + thread_current_mth = + (*env)->GetStaticMethodID (env, thread_class, "currentThread", + "()Ljava/lang/Thread;"); + if (!thread_current_mth) + { + BROKEN (env, "cannot find Thread.currentThread() method"); + return initialized = -1; + } + + thread_equals_mth = + (*env)->GetMethodID (env, thread_class, "equals", "(Ljava/lang/Object;)Z"); + if (!thread_equals_mth) + { + BROKEN (env, "cannot find Thread.equals() method"); + return initialized = -1; + } + + thread_join_mth = (*env)->GetMethodID (env, thread_class, "join", "()V"); + if (!thread_join_mth) + { + BROKEN (env, "cannot find Thread.join() method"); + return initialized = -1; + } + + thread_stop_mth = (*env)->GetMethodID (env, thread_class, "stop", "()V"); + if ( ! thread_stop_mth ) + { + BROKEN (env, "cannot find Thread.stop() method"); + return initialized = -1; + } + + thread_setPriority_mth = + (*env)->GetMethodID (env, thread_class, "setPriority", "(I)V"); + if ( ! thread_setPriority_mth ) + { + BROKEN (env, "cannot find Thread.setPriority() method"); + return initialized = -1; + } + + thread_yield_mth = + (*env)->GetStaticMethodID (env, thread_class, "yield", "()V"); + if ( ! thread_yield_mth ) + { + BROKEN (env, "cannot find Thread.yield() method"); + return initialized = -1; + } + + /* java.lang.ThreadLocal */ + lcl_class = (*env)->FindClass (env, "java/lang/ThreadLocal"); + if ( ! lcl_class ) + { + BROKEN (env, "cannot find class java.lang.ThreadLocal"); + return initialized = -1; + } + + /* Pin it down. */ + threadlocal_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if ( ! threadlocal_class ) + { + BROKEN (env, "Cannot get a global reference to java.lang.ThreadLocal"); + return initialized = -1; + } + + threadlocal_ctor = (*env)->GetMethodID (env, threadlocal_class, + "", "()V"); + if ( ! threadlocal_ctor ) + { + BROKEN (env, "cannot find ThreadLocal.()V"); + return initialized = -1; + } + + threadlocal_get_mth = (*env)->GetMethodID (env, threadlocal_class, + "get", "()Ljava/lang/Object;"); + if ( ! threadlocal_get_mth ) + { + BROKEN (env, "cannot find java.lang.ThreadLocal.get()Object"); + return initialized = -1; + } + + threadlocal_set_mth = (*env)->GetMethodID (env, threadlocal_class, + "set", "(Ljava/lang/Object;)V"); + if ( ! threadlocal_set_mth ) + { + BROKEN (env, "cannot find ThreadLocal.set(Object)V"); + return initialized = -1; + } + + /* java.lang.Long */ + lcl_class = (*env)->FindClass (env, "java/lang/Long"); + if ( ! lcl_class ) + { + BROKEN (env, "cannot find class java.lang.Long"); + return initialized = -1; + } + + /* Pin it down. */ + long_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!long_class) + { + BROKEN (env, "Cannot get a global reference to java.lang.Long"); + return initialized = -1; + } + + long_ctor = (*env)->GetMethodID (env, long_class, "", "(J)V"); + if (!long_ctor) + { + BROKEN (env, "cannot find method java.lang.Long.(J)V"); + return initialized = -1; + } + + long_longValue_mth = + (*env)->GetMethodID (env, long_class, "longValue", "()J"); + if (!long_longValue_mth) + { + BROKEN (env, "cannot find method java.lang.Long.longValue()J"); + return initialized = -1; + } + + + /* GThreadNativeMethodRunner */ + lcl_class = + (*env)->FindClass (env, + "gnu/java/awt/peer/gtk/GThreadNativeMethodRunner"); + if ( ! lcl_class ) + { + BROKEN (env, + "cannot find gnu.java.awt.peer.gtk.GThreadNativeMethodRunner"); + return initialized = -1; + } + + /* Pin it down. */ + runner_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!runner_class) + { + BROKEN (env, + "Cannot get a global reference to the class GThreadNativeMethodRunner"); + return initialized = -1; + } + + runner_ctor = (*env)->GetMethodID (env, runner_class, "", "(JJZ)V"); + if ( ! runner_ctor ) + { + BROKEN (env, + "cannot find method GThreadNativeMethodRunner.(JJZ)"); + return initialized = -1; + } + + runner_start_mth = (*env)->GetMethodID (env, runner_class, "start", "()V"); + if ( ! runner_start_mth ) + { + BROKEN (env, "cannot find method GThreadNativeMethodRunner.start()V"); + return initialized = -1; + } + + + runner_threadToThreadID_mth = + (*env)->GetStaticMethodID (env, runner_class, + "threadToThreadID", "(Ljava/lang/Thread;)I"); + if ( ! runner_threadToThreadID_mth ) + { + BROKEN (env, + "cannot find method GThreadNativeMethodRunner.threadToThreadID(java.lang.Thread)I"); + return initialized = -1; + } + + + runner_threadIDToThread_mth = + (*env)->GetStaticMethodID (env, runner_class, + "threadIDToThread", "(I)Ljava/lang/Thread;"); + if ( ! runner_threadIDToThread_mth ) + { + BROKEN (env, + "cannot find method GThreadNativeMethodRunner.threadIDToThread(I)java.lang.Thread"); + return initialized = -1; + } + + + runner_deRegisterJoinable_mth = + (*env)->GetStaticMethodID (env, runner_class, "deRegisterJoinable", + "(Ljava/lang/Thread;)V"); + if (!runner_deRegisterJoinable_mth) + { + BROKEN (env, + "cannot find method GThreadNativeMethodRunner.deRegisterJoinable(java.lang.Thread)V"); + return initialized = -1; + } + + + /* java.lang.InterruptedException */ + lcl_class = (*env)->FindClass (env, "java/lang/InterruptedException"); + if ( ! lcl_class ) + { + BROKEN (env, "cannot find class java.lang.InterruptedException"); + return initialized = -1; + } + + /* Pin it down. */ + interrupted_exception_class = (jclass) (*env)->NewGlobalRef (env, lcl_class); + DELETE_LOCAL_REF (env, lcl_class); + if (!interrupted_exception_class) + { + BROKEN (env, "Cannot make a global reference" + " to java.lang.InterruptedException"); + return initialized = -1; + } + +#ifdef JNI_VERSION_1_2 + if (HAVE_JNI_VERSION_1_2) + assert ( ! (*env)->ExceptionCheck (env)); + else +#endif + assert ( ! (*env)->ExceptionOccurred (env)); + + + return initialized = 1; +} + + - jstring jmessage; - jclass obj_class; - jobject obj; - jmethodID ctor; - int len; - char *buf; - - /* rethrow if an exception happened */ - if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) - { - - /* allocate local message in Java */ - len = strlen(message) + strlen(file) + 25; - buf = (char *) malloc(len); - if (buf != NULL) - { - bzero(buf, len); - sprintf(buf, "%s (at %s:%d)", message, file, line); - jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf); - free(buf); - } - else - jmessage = NULL; - - /* create RuntimeException wrapper object */ - obj_class = (*gdk_env)->FindClass (gdk_env, - "java/lang/RuntimeException"); - ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "", - "(Ljava/langString;Ljava/lang/Throwable)V"); - obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause); - - /* throw it */ - (*gdk_env)->Throw(gdk_env, (jthrowable)obj); - } -} - -/* This macro is used to include a source location in the exception message */ -#define MAYBE_RETHROW(_class, _message) \ -maybe_rethrow(_class, _message, __FILE__, __LINE__) /************************************************************************/ /* Utilities to allocate and free java.lang.Objects */ /************************************************************************/ -/* Both the mutexes and the condition variables are java.lang.Object objects, +/* The condition variables are java.lang.Object objects, * which this method allocates and returns a global ref. Note that global * refs must be explicitly freed (isn't C fun?). */ -static jobject *allocatePlainObject() { - jclass obj_class; - jobject *obj; - JNIEnv *gdk_env; - jmethodID ctor; - - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); +static jobject +allocatePlainObject (JNIEnv * env) +{ + jobject lcl_obj, global_obj; - obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/Object"); - MAYBE_RETHROW(gdk_env, "cannot find Object"); + lcl_obj = (*env)->NewObject (env, obj_class, obj_ctor); + if (!lcl_obj) + { + BROKEN (env, "cannot allocate object"); + return NULL; + } - ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "", "()V"); - MAYBE_RETHROW(gdk_env, "cannot find constructor"); + global_obj = (*env)->NewGlobalRef (env, lcl_obj); + DELETE_LOCAL_REF (env, lcl_obj); + if (!global_obj) + { + NEW_BROKEN (env, "cannot make global ref for a new plain Java object"); + /* Deliberate fall-through */ + } - obj = (jobject *) g_malloc (sizeof (jobject)); - *obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor); - MAYBE_RETHROW(gdk_env, "cannot allocate object"); - - *obj = (*gdk_env)->NewGlobalRef (gdk_env, *obj); - MAYBE_RETHROW(gdk_env, "cannot make global ref"); + return global_obj; +} - return obj; +/* Frees any Java object given a global ref (isn't C fun?) */ +static void +freeObject (JNIEnv * env, jobject obj) +{ + if (obj) + { + (*env)->DeleteGlobalRef (env, obj); + /* DeleteGlobalRef can never fail */ + } } -/* Frees a Java object given a global ref (isn't C fun?) */ -static void freePlainObject(jobject *obj) { - JNIEnv *gdk_env; - if (obj) { - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); +/************************************************************************/ +/* Utilities to allocate and free Java mutexes */ +/************************************************************************/ - (*gdk_env)->DeleteGlobalRef (gdk_env, *obj); - MAYBE_RETHROW(gdk_env, "cannot delete global ref"); - - g_free (obj); - } +/* The mutexes are gnu.java.awt.peer.gtk.GThreadMutex objects, + * which this method allocates and returns a global ref. Note that global + * refs must be explicitly freed (isn't C fun?). + * + * Free this with freeObject() + */ +static jobject +allocateMutexObject (JNIEnv * env) +{ + jobject lcl_obj, global_obj; + + lcl_obj = (*env)->NewObject (env, mutex_class, mutex_ctor); + if (!lcl_obj) + { + BROKEN (env, "cannot allocate a GThreadMutex"); + return NULL; + } + + global_obj = (*env)->NewGlobalRef (env, lcl_obj); + DELETE_LOCAL_REF (env, lcl_obj); + if (!global_obj) + { + NEW_BROKEN (env, "cannot make global ref"); + /* Deliberate fallthrough */ + } + + return global_obj; } @@ -184,195 +1208,746 @@ static void freePlainObject(jobject *obj) { /************************************************************************/ /* Lock a Java object */ -static void takeLock(JNIEnv *gdk_env, void *mutex) { - (*gdk_env)->MonitorEnter (gdk_env, *((jobject *)mutex)); - MAYBE_RETHROW(gdk_env, "cannot get lock"); +#define ENTER_MONITOR(env, m) \ + enterMonitor(env, m, G_STRINGIFY(m)) + +/* Return -1 on failure, 0 on success. */ +static int +enterMonitor (JNIEnv * env, jobject monitorObj, const char monName[]) +{ + if (TRACE_MONITORS) + tracing (" ", monName); + assert (monitorObj); + if ((*env)->MonitorEnter (env, monitorObj) < 0) + { + BROKEN (env, "cannot enter monitor"); + return -1; + } + return 0; } + /* Unlock a Java object */ -static void releaseLock(JNIEnv *gdk_env, void *mutex) { - (*gdk_env)->MonitorExit (gdk_env, *((jobject *)mutex)); - MAYBE_RETHROW(gdk_env, "cannot release lock"); +#define EXIT_MONITOR(env, m) \ + exitMonitor(env, m, G_STRINGIFY(m)) + +static int +exitMonitor (JNIEnv * env, jobject mutexObj, const char monName[]) +{ + if (TRACE_MONITORS) + tracing (" ", monName); + assert (mutexObj); + if ((*env)->MonitorExit (env, mutexObj) < 0) + { + BROKEN (env, "cannot exit monitor "); + return -1; + } + return 0; } -/* Create a mutex, which is a java.lang.Object for us */ -static GMutex *g_mutex_new_jni_impl (void) { - return (GMutex*) allocatePlainObject(); + +/************************************************************************/ +/* Miscellaneous utilities */ +/************************************************************************/ + +/* Get the Java Thread object that corresponds to a particular thread ID. + A negative thread Id gives us a null object. + + Returns a local reference. +*/ +static jobject +getThreadFromThreadID (JNIEnv * env, gpointer gThreadID) +{ + jint threadNum = (jint) gThreadID; + jobject thread; + + if (threadNum < 0) + { + NEW_BROKEN (env, "getThreadFromThreadID asked to look up" + " a negative thread index"); + return NULL; + } + + thread = (*env)->CallStaticObjectMethod + (env, runner_class, runner_threadIDToThread_mth, threadNum); + + if (MAYBE_BROKEN (env, "cannot get Thread for threadID ")) + return NULL; + + return thread; +} + +/** Return the unique threadID of THREAD. + + Error handling: Return (gpointer) -1 on all failures, + and propagate an exception. +*/ +static gpointer +getThreadIDFromThread (JNIEnv * env, jobject thread) +{ + jint threadNum; + + if (ENABLE_EXPENSIVE_ASSERTIONS) + assert ((*env)->IsInstanceOf (env, thread, thread_class)); + + HIDE_OLD_TROUBLE (env); + + threadNum = (*env)->CallStaticIntMethod + (env, runner_class, runner_threadToThreadID_mth, thread); + + if (MAYBE_BROKEN (env, "cannot get ThreadID for a Thread ")) + { + threadNum = -1; + goto done; + } + + + SHOW_OLD_TROUBLE (); + +done: + return (gpointer) threadNum; +} + + +/************************************************************************/ +/* The Actual JNI functions that we pass to the function vector. */ +/************************************************************************/ + + +/************************************************************************/ +/* Mutex Functions */ +/************************************************************************/ + +/*** Mutex Utilities ****/ +struct mutexObj_cache +{ + jobject lockForPotentialLockersObj; /* Lock for the potentialLockers + field. Local reference. */ + jobject lockObj; /* The real lock we use. This is a GLOBAL + reference and must not be freed. */ +}; + +/* Initialize the cache of sub-locks for a particular mutex object. + + -1 on error, 0 on success. The caller is not responsible for freeing the + partially-populated cache in case of failure (but in practice does anyway) + (This actually never fails, though, since GetObjectField allegedly never + fails.) + + Guaranteed to leave all fields of the cache initialized, even if only to + zero. +*/ +static int +populate_mutexObj_cache (JNIEnv * env, jobject mutexObj, + struct mutexObj_cache *mcache) +{ + mcache->lockObj = mutexObj; /* the mutexObj is its own lock. */ + assert (mcache->lockObj); + + mcache->lockForPotentialLockersObj = (*env)->GetObjectField + (env, mutexObj, mutex_lockForPotentialLockers_fld); + /* GetObjectField can never fail. */ + + /* Retrieving a NULL object could only happen if we somehow got a + a mutex object that was not properly intialized. */ + assert (mcache->lockForPotentialLockersObj); + + return 0; +} + + +/* Clean out the mutexObj_cache, even if it was never populated. */ +static void +clean_mutexObj_cache (JNIEnv * env, struct mutexObj_cache *mcache) +{ + /* OK to pass NULL refs to DELETE_LOCAL_REF */ + DELETE_LOCAL_REF (env, mcache->lockForPotentialLockersObj); + /* mcache->lockObj is a GLOBAL reference. */ + mcache->lockObj = NULL; +} + +/* -1 on failure, 0 on success. + The mutexObj_cache is already populated for this particular object. */ +static int +mutexObj_lock (JNIEnv * env, jobject mutexObj, struct mutexObj_cache *mcache) +{ + jint potentialLockers; + + if (ENTER_MONITOR (env, mcache->lockForPotentialLockersObj)) + return -1; + + assert(mutexObj); + potentialLockers = + (*env)->GetIntField (env, mutexObj, mutex_potentialLockers_fld); + /* GetIntField() never fails. */ + + ++potentialLockers; + + (*env)->SetIntField + (env, mutexObj, mutex_potentialLockers_fld, potentialLockers); + + if (EXIT_MONITOR (env, mcache->lockForPotentialLockersObj)) + return -1; + + if (ENTER_MONITOR (env, mcache->lockObj)) + return -1; + + SHOW_OLD_TROUBLE (); + + return 0; +} + +/* Unlock a GMutex, once we're already in JNI and have already gotten the + mutexObj for it. This skips the messages that TRACE_API_CALLS would + print. + + Returns -1 on error, 0 on success. */ +static int +mutexObj_unlock (JNIEnv * env, jobject mutexObj, + struct mutexObj_cache *mcache) +{ + jint potentialLockers; + int ret = -1; /* assume failure until we suceed. */ + + /* Free the lock first, so that someone waiting for the lock can get it + ASAP. */ + /* This is guaranteed not to block. */ + if (EXIT_MONITOR (env, mcache->lockObj) < 0) + goto done; + + /* Kick down potentialLockers by one. We do this AFTER we free the lock, so + that we hold it no longer than necessary. */ + if (ENTER_MONITOR (env, mcache->lockForPotentialLockersObj) < 0) + goto done; + + potentialLockers = (*env)->GetIntField + (env, mutexObj, mutex_potentialLockers_fld); + /* GetIntField never fails */ + + assert (potentialLockers >= 1); + --potentialLockers; + + (*env)->SetIntField + (env, mutexObj, mutex_potentialLockers_fld, potentialLockers); + /* Never fails, so the JNI book says. */ + + /* Clean up. */ + if (EXIT_MONITOR (env, mcache->lockForPotentialLockersObj) < 0) + goto done; + ret = 0; + +done: + return ret; +} + +/*** Mutex Implementations ****/ + +/* Create a mutex, which is a java.lang.Object for us. + In case of failure, we'll return NULL. Which will implicitly + cause future calls to fail. */ +static GMutex * +mutex_new_jni_impl (void) +{ + jobject mutexObj; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("mutex_new_jni_impl()"); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + if (setup_cache (env) < 0) + { + mutexObj = NULL; + goto done; + } + + mutexObj = allocateMutexObject (env); + +done: + if (TRACE_API_CALLS) + tracing (" ==> %p \n", mutexObj); + + return (GMutex *) mutexObj; + } /* Lock a mutex. */ -static void g_mutex_lock_jni_impl (GMutex *mutex __attribute__((unused))) { - JNIEnv *gdk_env; +static void +mutex_lock_jni_impl (GMutex * mutex) +{ + struct mutexObj_cache mcache; + jobject mutexObj = (jobject) mutex; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("mutex_lock_jni_impl( mutexObj = %p )", mutexObj); + + assert (mutexObj); + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + if (setup_cache (env) < 0) + goto done; - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + HIDE_OLD_TROUBLE (env); - takeLock(gdk_env, mutex); + if (populate_mutexObj_cache (env, mutexObj, &mcache) < 0) + goto done; + + mutexObj_lock (env, mutexObj, &mcache); + /* No need to error check; we've already reported it in any case. */ + +done: + clean_mutexObj_cache (env, &mcache); + if (TRACE_API_CALLS) + tracing (" ==> VOID \n"); } -/* Try to lock a mutex. Actually, do not try because Java objects - * do not provide such an interface. To be at least minimally correct, - * pretend we tried and failed. - */ -static gboolean g_mutex_trylock_jni_impl - (GMutex *mutex __attribute__((unused))) + +/* Try to lock a mutex. Return TRUE if we succeed, FALSE if we fail. + FALSE on error. */ +static gboolean +mutex_trylock_jni_impl (GMutex * gmutex) { - /* XXX Shall we implement this in a VM-specific way under a flag? */ - return FALSE; + jobject mutexObj = (jobject) gmutex; + jint potentialLockers; + gboolean ret = FALSE; + JNIEnv *env; + union env_union e; + struct mutexObj_cache mcache; + + if (TRACE_API_CALLS) + tracing ("mutex_trylock_jni_impl(mutexObj=%p)", mutexObj); + + assert (mutexObj); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + if (populate_mutexObj_cache (env, mutexObj, &mcache) < 0) + goto done; + + if (ENTER_MONITOR (env, mcache.lockForPotentialLockersObj)) + goto done; + + potentialLockers = (*env)->GetIntField + (env, mutexObj, mutex_potentialLockers_fld); + + assert (potentialLockers >= 0); + + if (potentialLockers) + { + /* Already locked. Clean up and leave. */ + EXIT_MONITOR (env, mcache.lockForPotentialLockersObj); + /* Ignore any error code from EXIT_MONITOR; there's nothing we could do + at this level, in any case. */ + goto done; + } + + /* Guaranteed not to block. */ + if (ENTER_MONITOR (env, mcache.lockObj)) + { + /* Clean up the existing lock. */ + EXIT_MONITOR (env, mcache.lockForPotentialLockersObj); + /* Ignore any error code from EXIT_MONITOR; there's nothing we could do + at this level, in any case. */ + goto done; + } + + + /* We have the monitor. Record that fact. */ + potentialLockers = 1; + (*env)->SetIntField + (env, mutexObj, mutex_potentialLockers_fld, potentialLockers); + /* Set*Field() never fails */ + + ret = TRUE; /* We have the lock. */ + + /* Clean up. */ + if (EXIT_MONITOR (env, mcache.lockForPotentialLockersObj)) + goto done; /* If we fail at this point, still keep the + main lock. */ + + SHOW_OLD_TROUBLE (); +done: + clean_mutexObj_cache (env, &mcache); + if (TRACE_API_CALLS) + tracing (" ==> %s\n", ret ? "TRUE" : "FALSE"); + return ret; } + /* Unlock a mutex. */ -static void g_mutex_unlock_jni_impl (GMutex *mutex) { - JNIEnv *gdk_env; +static void +mutex_unlock_jni_impl (GMutex * gmutex) +{ + jobject mutexObj = (jobject) gmutex; + struct mutexObj_cache mcache; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("mutex_unlock_jni_impl(mutexObj=%p)", mutexObj); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + assert (mutexObj); - releaseLock(gdk_env, mutex); + if ( populate_mutexObj_cache (env, mutexObj, &mcache) < 0) + goto done; + + (void) mutexObj_unlock (env, mutexObj, &mcache); + + SHOW_OLD_TROUBLE (); + +done: + clean_mutexObj_cache (env, &mcache); + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } -/* Free a mutex (isn't C fun?) */ -static void g_mutex_free_jni_impl (GMutex *mutex) + + +/* Free a mutex (isn't C fun?). OK this time for it to be NULL. + No failure conditions, for a change. */ +static void +mutex_free_jni_impl (GMutex * mutex) { - freePlainObject( (jobject*)mutex ); + jobject mutexObj = (jobject) mutex; + JNIEnv *env; + union env_union e; + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + if (TRACE_API_CALLS) + tracing ("mutex_free_jni_impl(%p)", mutexObj); + + freeObject (env, mutexObj); + + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } + + /************************************************************************/ /* Condition variable code */ /************************************************************************/ /* Create a new condition variable. This is a java.lang.Object for us. */ -static GCond *g_cond_new_jni_impl () { - return (GCond*)allocatePlainObject(); +static GCond * +cond_new_jni_impl (void) +{ + jobject condObj; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("mutex_free_jni_impl()"); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + condObj = allocatePlainObject (env); + + if (TRACE_API_CALLS) + tracing (" ==> %p\n", condObj); + + return (GCond *) condObj; } /* Signal on a condition variable. This is simply calling Object.notify * for us. */ -static void g_cond_signal_jni_impl (GCond *cond) { - jclass lcl_class; - jmethodID signal_mth; - JNIEnv *gdk_env; +static void +cond_signal_jni_impl (GCond * gcond) +{ + JNIEnv *env; + union env_union e; + jobject condObj = (jobject) gcond; - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + if (TRACE_API_CALLS) + tracing ("cond_signal_jni_impl(condObj = %p)", condObj); - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object"); - MAYBE_RETHROW(gdk_env, "cannot find Object"); - - signal_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "notify", "()V"); - MAYBE_RETHROW(gdk_env, "cannot find Object."); + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + assert (condObj); /* Must have locked an object to call notify */ - takeLock(gdk_env, cond); + if (ENTER_MONITOR (env, condObj)) + goto done; + + (*env)->CallVoidMethod (env, condObj, obj_notify_mth); + if (MAYBE_BROKEN (env, "cannot signal mutex with Object.notify()")) + { + if (EXIT_MONITOR (env, condObj)) + BADLY_BROKEN1 ("Failed to unlock a monitor; the VM may deadlock."); + goto done; + } - (*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, signal_mth); - MAYBE_RETHROW(gdk_env, "cannot signal mutex"); + EXIT_MONITOR (env, condObj); - releaseLock(gdk_env, cond); + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } /* Broadcast to all waiting on a condition variable. This is simply * calling Object.notifyAll for us. */ -static void g_cond_broadcast_jni_impl (GCond *cond) { - jclass lcl_class; - jmethodID bcast_mth; - JNIEnv *gdk_env; +static void +cond_broadcast_jni_impl (GCond * gcond) +{ + jobject condObj = (jobject) gcond; + JNIEnv *env; + union env_union e; - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + if (TRACE_API_CALLS) + tracing ("cond_broadcast_jni_impl(condObj=%p)", condObj); - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object"); - MAYBE_RETHROW(gdk_env, "cannot find Object"); - - bcast_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "notifyAll", "()V"); - MAYBE_RETHROW(gdk_env, "cannot find Object."); + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + assert (condObj); /* Must have locked an object to call notifyAll */ - takeLock(gdk_env, cond); + if (ENTER_MONITOR (env, condObj)) + goto done; + + (*env)->CallVoidMethod (env, condObj, obj_notifyall_mth); + if (MAYBE_BROKEN (env, "cannot broadcast to mutex with Object.notify()")) + { + EXIT_MONITOR (env, condObj); + goto done; + } - (*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, bcast_mth); - MAYBE_RETHROW(gdk_env, "cannot broadcast to mutex"); + EXIT_MONITOR (env, condObj); - releaseLock(gdk_env, cond); + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } -/* Wait on a condition variable. For us, this simply means call +/* Wait on a condition variable. For us, this simply means calling * Object.wait. + * + * Throws a Java exception on trouble; may leave the mutexes set arbitrarily. + * XXX TODO: Further improve error recovery. */ -static void g_cond_wait_jni_impl - (GCond *cond, GMutex *mutex __attribute__((unused))) +static void +cond_wait_jni_impl (GCond * gcond, GMutex * gmutex) { - jclass lcl_class; - jmethodID wait_mth; - JNIEnv *gdk_env; + struct mutexObj_cache cache; + jobject condObj = (jobject) gcond; + jobject mutexObj = (jobject) gmutex; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("cond_wait_jni_impl(condObj=%p, mutexObj=%p)", + condObj, mutexObj); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + assert (condObj); + assert (mutexObj); + /* Must have locked a Java object to call wait on it */ + if (ENTER_MONITOR (env, condObj) < 0) + goto done; + + /* Our atomicity is now guaranteed; we're protected by the Java monitor on + condObj. Unlock the GMutex. */ + if (mutexObj_unlock (env, mutexObj, &cache)) + goto done; + + (*env)->CallVoidMethod (env, condObj, obj_wait_mth); + if (MAYBE_BROKEN (env, "cannot wait on condObj")) + { + EXIT_MONITOR (env, condObj); /* ignore err checking */ + goto done; + } - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + /* Re-acquire the lock on the GMutex. Do this while we're protected by the + Java monitor on condObj. */ + if (mutexObj_lock (env, mutexObj, &cache)) + goto done; - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object"); - MAYBE_RETHROW(gdk_env, "cannot find Object"); - - wait_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "wait", "()V"); - MAYBE_RETHROW(gdk_env, "cannot find Object."); + EXIT_MONITOR (env, condObj); - /* Must have locked an object to call wait */ - takeLock(gdk_env, cond); + SHOW_OLD_TROUBLE (); - (*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, wait_mth); - MAYBE_RETHROW(gdk_env, "cannot wait on mutex"); - - releaseLock(gdk_env, cond); +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } -/* Wait on a condition vairable until a timeout. This is a little tricky + +/** Wait on a condition variable until a timeout. This is a little tricky * for us. We first call Object.wait(J) giving it the appropriate timeout * value. On return, we check whether an InterruptedException happened. If - * so, that is Java-speak for wait timing out. + * so, that is Java-speak for wait timing out. + * + * We return FALSE if we timed out. Return TRUE if the condition was + * signalled first, before we timed out. + * + * In case of trouble we throw a Java exception. Whether we return FALSE or + * TRUE depends upon whether the condition was raised before the trouble + * happened. + * + * I believe that this function goes to the proper lengths to try to unlock + * all of the locked mutexes and monitors, as appropriate, and that it further + * tries to make sure that the thrown exception is the current one, not any + * future cascaded one from something like a failure to unlock the monitors. */ static gboolean -g_cond_timed_wait_jni_impl - (GCond *cond, GMutex *mutex __attribute__((unused)), - GTimeVal *end_time) +cond_timed_wait_jni_impl (GCond * gcond, GMutex * gmutex, GTimeVal * end_time) { - jclass lcl_class; - jmethodID wait_mth; - JNIEnv *gdk_env; - jlong time; + JNIEnv *env; + union env_union e; + jlong time_millisec; + jint time_nanosec; jthrowable cause; + jobject condObj = (jobject) gcond; + jobject mutexObj = (jobject) gmutex; + gboolean condRaised = FALSE; /* Condition has not been raised yet. */ + struct mutexObj_cache cache; + gboolean interrupted; + + if (TRACE_API_CALLS) + { + tracing ("cond_timed_wait_jni_impl(cond=%p, mutex=%p," + " end_time=< sec=%lu, usec=%lu >)", condObj, mutexObj, + (unsigned long) end_time->tv_sec, + (unsigned long) end_time->tv_usec); + } - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Object"); - MAYBE_RETHROW(gdk_env, "cannot find Object"); - - wait_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "wait", "(J)V"); - MAYBE_RETHROW(gdk_env, "cannot find Object."); - - time = end_time->tv_sec*1000; - time += end_time->tv_usec/1000; + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + time_millisec = end_time->tv_sec * 1000 + end_time->tv_usec / 1000; + time_nanosec = 1000 * (end_time->tv_usec % 1000); /* Must have locked an object to call wait */ - takeLock(gdk_env, cond); + if (ENTER_MONITOR (env, condObj) < 0) + goto done; + + if (mutexObj_unlock (env, mutexObj, &cache) < 0) + { + if (EXIT_MONITOR (env, condObj) < 0) + criticalMsg + ("Unable to unlock an existing lock on a condition; your proram may deadlock"); + goto done; + } + + + (*env)->CallVoidMethod (env, condObj, obj_wait_nanotime_mth, + time_millisec, time_nanosec); + + /* If there was trouble, save that fact, and the reason for the trouble. We + want to respond to this condition as fast as possible. */ + cause = (*env)->ExceptionOccurred (env); + + if ( ! cause ) + { + condRaised = TRUE; /* condition was signalled */ + } + else if ((*env)->IsInstanceOf (env, cause, interrupted_exception_class)) + { + condRaised = FALSE; /* Condition was not raised before timeout. + (This is redundant with the initialization + of condRaised above) */ + (*env)->ExceptionClear (env); /* Clear the InterruptedException. */ + cause = NULL; /* no pending cause now. */ + } + else + { + interrupted = FALSE; /* Trouble, but not because of + InterruptedException. Assume the condition + was not raised. */ + /* Leave condRaised set to FALSE */ + } - (*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)cond, wait_mth, time); + /* Irrespective of whether there is a pending problem to report, go ahead + and try to clean up. This may end up throwing an exception that is + different from the one that was thrown by the call to Object.wait(). + So we will override it with the first exception (don't want to have + cascading problems). */ + if (mutexObj_lock (env, mutexObj, &cache) && !cause) + { + cause = (*env)->ExceptionOccurred (env); + assert (cause); + } - if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) { - jclass intr = (*gdk_env)->FindClass (gdk_env, "java.lang.InterruptedException"); - if ( (*gdk_env)->IsInstanceOf(gdk_env, cause, intr) ) { - releaseLock(gdk_env, cond); - return FALSE; - } else { - MAYBE_RETHROW(gdk_env, "error in timed wait"); + if (EXIT_MONITOR (env, condObj) && !cause) + { + cause = (*env)->ExceptionOccurred (env); + assert (cause); } - } - releaseLock(gdk_env, cond); + if (cause) /* Raise the first cause. */ + { + BROKEN_CAUSE (env, cause, "error in timed wait or during its cleanup"); + goto done; + } + + SHOW_OLD_TROUBLE (); - return TRUE; +done: + if (TRACE_API_CALLS) + tracing (" ==> condRaised = %s\n", condRaised ? "TRUE" : "FALSE"); + return condRaised; } -/* Free a condition variable. (isn't C fun?) */ -static void g_cond_free_jni_impl (GCond *cond) { - freePlainObject( (jobject*)cond ); + +/* Free a condition variable. (isn't C fun?). Can not fail. */ +static void +cond_free_jni_impl (GCond * cond) +{ + jobject condObj = (jobject) cond; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("cond_free_jni_impl(condObj = %p)", condObj); + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + freeObject (env, condObj); + + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); } @@ -380,128 +1955,638 @@ static void g_cond_free_jni_impl (GCond *cond) { /* Thread-local data code */ /************************************************************************/ -/* Create a new thread-local key. We use java.lang.ThreadLocal objects - * for this. +/* Create a new thread-local key. We use java.lang.ThreadLocal objects + * for this. This returns the pointer representation of a Java global + * reference. + * + * We will throw a Java exception and return NULL in case of failure. */ -static GPrivate *g_private_new_jni_impl - (GDestroyNotify notify __attribute__((unused))) +static GPrivate * +private_new_jni_impl (GDestroyNotify notify __attribute__ ((unused))) { - jclass lcl_class; - jobject *local; - JNIEnv *gdk_env; - jmethodID ctor; + JNIEnv *env; + union env_union e; + jobject lcl_key; + jobject global_key; + GPrivate *gkey = NULL; /* Error return code */ + + if (TRACE_API_CALLS) + tracing ("private_new_jni_impl()"); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + lcl_key = (*env)->NewObject (env, threadlocal_class, threadlocal_ctor); + if ( ! lcl_key ) + { + BROKEN (env, "cannot allocate a ThreadLocal"); + goto done; + } - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); + global_key = ((*env)->NewGlobalRef (env, lcl_key)); + DELETE_LOCAL_REF (env, lcl_key); + if ( ! global_key) + { + NEW_BROKEN (env, "cannot create a GlobalRef to a new ThreadLocal"); + goto done; + } - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal"); + gkey = (GPrivate *) global_key; + SHOW_OLD_TROUBLE (); - ctor = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "", "()V"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal."); +done: + if (TRACE_API_CALLS) + tracing (" ==> %p\n", (void *) gkey); - local = (jobject *) g_malloc (sizeof (jobject)); - *local = (*gdk_env)->NewObject(gdk_env, lcl_class, ctor); - MAYBE_RETHROW(gdk_env, "cannot allocate a ThreadLocal"); - - *local = ((*gdk_env)->NewGlobalRef (gdk_env, *local)); - MAYBE_RETHROW(gdk_env, "cannot create a GlobalRef"); - - return (GPrivate*) local; + return gkey; } /* Get this thread's value for a thread-local key. This is simply - * ThreadLocal.get for us. + * ThreadLocal.get for us. Return NULL if no value. (I can't think of + * anything else to do.) */ -static gpointer g_private_get_jni_impl (GPrivate *private) { - jclass lcl_class; - jobject lcl_obj; - JNIEnv *gdk_env; - jmethodID get_mth; - jclass int_class; - jmethodID val_mth; - jint int_val; - - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); +static gpointer +private_get_jni_impl (GPrivate * gkey) +{ + JNIEnv *env; + union env_union e; + jobject val_wrapper; + jobject keyObj = (jobject) gkey; + gpointer thread_specific_data = NULL; /* Init to the error-return value */ + + jlong val; + + if (TRACE_API_CALLS) + tracing ("private_get_jni_impl(keyObj=%p)", keyObj); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + val_wrapper = (*env)->CallObjectMethod (env, keyObj, threadlocal_get_mth); + if (MAYBE_BROKEN (env, "cannot find thread-local object")) + goto done; + + if (! val_wrapper ) + { + /* It's Java's "null" object. No ref found. This is OK; we must never + have set a value in this thread. Note that this next statement is + not necessary, strictly speaking, since we're already initialized to + NULL. A good optimizing C compiler will detect that and optimize out + this statement. */ + thread_specific_data = NULL; + goto done; + } - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal"); + val = (*env)->CallLongMethod (env, val_wrapper, long_longValue_mth); - get_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "get", "()Ljava/lang/Object;"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal."); + if (MAYBE_BROKEN (env, "cannot get thread local value")) + goto done; - lcl_obj = (*gdk_env)->CallObjectMethod(gdk_env, *(jobject*)private, get_mth); - MAYBE_RETHROW(gdk_env, "cannot find thread-local object"); + thread_specific_data = (gpointer) (intptr_t) val; - int_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Integer"); - MAYBE_RETHROW(gdk_env, "cannot find Integer"); + /* Only re-raise the old pending exception if a new one hasn't come along to + supersede it. */ + SHOW_OLD_TROUBLE (); - val_mth = (*gdk_env)->GetMethodID(gdk_env, int_class, "intValue", "()I"); - MAYBE_RETHROW(gdk_env, "cannot find Integer."); +done: - int_val = (*gdk_env)->CallIntMethod(gdk_env, lcl_obj, val_mth); - MAYBE_RETHROW(gdk_env, "cannot get thread local value"); + if (TRACE_API_CALLS) + tracing (" ==> %p\n", thread_specific_data); - return (gpointer) int_val; + return thread_specific_data; } -/* Set this thread's value for a thread-local key. This is simply - * ThreadLocal.set for us. +/* Set this thread's value for a thread-local key. This is simply + * ThreadLocal.set() for us. */ -static void g_private_set_jni_impl (GPrivate *private, gpointer data) { - jclass lcl_class, int_class; - jobject lcl_obj; - JNIEnv *gdk_env; - jmethodID new_int, set_mth; +static void +private_set_jni_impl (GPrivate * gkey, gpointer thread_specific_data) +{ + JNIEnv *env; + union env_union e; + jobject val_wrapper; + jobject keyObj = (jobject) gkey; + + + if (TRACE_API_CALLS) + tracing ("private_set_jni_impl(keyObj=%p, thread_specific_data=%p)", + keyObj, thread_specific_data); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + /* We are just going to always use a Java long to represent a C pointer. + Otherwise all of the code would end up being conditionalized for various + pointer sizes, and that seems like too much of a hassle, in order to save + a paltry few bytes, especially given the horrendous overhead of JNI in + any case. + */ + + val_wrapper = (*env)->NewObject (env, long_class, long_ctor, + (jlong) (intptr_t) thread_specific_data); + if ( ! val_wrapper ) + { + BROKEN (env, "cannot create a java.lang.Long"); + goto done; + } + + /* At this point, we now have set lcl_obj as a numeric class that wraps + around the thread-specific data we were given. */ + (*env)->CallVoidMethod (env, keyObj, threadlocal_set_mth, val_wrapper); + if (MAYBE_BROKEN (env, "cannot set thread local value")) + goto done; + + SHOW_OLD_TROUBLE (); +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); +} + + +/** Create an object of type gnu.java.awt.peer.gtk.GThreadNativeMethodRunner. + Run it. + + We need to create joinable threads. We handle the notion of a joinable + thread by determining whether or not we are going to maintain a permanent + hard reference to it until it croaks. + + Posix does not appear to have a Java-like concept of daemon threads, where + the JVM will exit when there are only daemon threads running. + + Error handling: + + To quote from the glib guide: + "GError should only be used to report recoverable runtime errors, never + to report programming errors." + + So how do we consider the failure to create a thread? Well, each of the + failure cases in this function are discussed, and none of them are really + recoverable. + + The glib library is really designed so that you should fail + catastrophically in case of "programming errors". The only error defined + for the GThread functions is G_THREAD_ERROR_AGAIN, and that for + thread_create. + + Most of these GThread functions could fail if we run out of memory, for + example, but the only one capable of reporting that fact is + thread_create. */ +static void +thread_create_jni_impl (GThreadFunc func, + gpointer data, + gulong stack_size __attribute__((unused)), + gboolean joinable, + gboolean bound __attribute__((unused)), + GThreadPriority gpriority, + /* This prototype is horrible. threadIDp is actually + a gpointer to the thread's thread-ID. Which is, + of course, itself a gpointer-typed value. Ouch. */ + gpointer threadIDp, + /* Do not touch the GError stuff unless you have + RECOVERABLE trouble. There is no recoverable + trouble in this implementation. */ + GError **errorp __attribute__((unused))) +{ + JNIEnv *env; + union env_union e; + union func_union f; + jboolean jjoinable = joinable; + jobject newThreadObj; + gpointer threadID; /* to be filled in */ + + if (TRACE_API_CALLS) + { + f.g_func = func; + tracing ("thread_create_jni_impl(func=%p, data=%p, joinable=%s," + " threadIDp=%p, *(int *) threadIDp = %d)", + f.void_func, data, joinable ? "TRUE" : "FALSE", + threadIDp, *(int *) threadIDp); + } + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + { + /* The failed call to setup the cache is certainly not recoverable; + not appropriate for G_THREAD_ERROR_AGAIN. */ + *(gpointer *) threadIDp = NULL; + goto done; + } + HIDE_OLD_TROUBLE (env); + + /* If a thread is joinable, then notify its constructor. The constructor + will enter a hard reference for it, and the hard ref. won't go away until + the thread has been joined. */ + newThreadObj = + (*env)->NewObject (env, runner_class, runner_ctor, + (jlong) (intptr_t) func, (jlong) (intptr_t) data, + jjoinable); + if ( ! newThreadObj ) + { + BROKEN (env, "creating a new thread failed in the constructor"); + *(gpointer *) threadIDp = NULL; + /* The failed call to the constructor does not throw any errors such + that G_THREAD_ERROR_AGAIN is appropriate. No other recoverable + errors defined. Once again, we go back to the VM. */ + goto done; + } + + if (threadObj_set_priority (env, newThreadObj, gpriority) < 0) + { + *(gpointer *) threadIDp = NULL; + /* None of these possible exceptions from Thread.setPriority() are + recoverable, so they are not appropriate for EAGAIN. So we should + fail. */ + goto done; + } + + (*env)->CallVoidMethod (env, runner_class, runner_start_mth); + + if (MAYBE_BROKEN (env, "starting a new thread failed")) + { + *(gpointer *) threadIDp = NULL; + /* The only exception Thread.start() throws is + IllegalStateException. And that would indicate a programming error. + + So there are no situations such that G_THREAD_ERROR_AGAIN would be + OK. + + So, we don't use g_set_error() here to perform any error reporting. + */ + goto done; + } + + threadID = getThreadIDFromThread (env, newThreadObj); + + *(gpointer *) threadIDp = threadID; + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> (threadID = %p) \n", threadID); +} + + +/* Wraps a call to g_thread_yield. */ +static void +thread_yield_jni_impl (void) +{ + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("thread_yield_jni_impl()"); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + (*env)->CallStaticVoidMethod (env, thread_class, thread_yield_mth); + if (MAYBE_BROKEN (env, "Thread.yield() failed")) + goto done; + + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); +} + + +static void +thread_join_jni_impl (gpointer threadID) +{ + JNIEnv *env; + union env_union e; + jobject threadObj = NULL; + + if ( TRACE_API_CALLS ) + tracing ("thread_join_jni_impl(threadID=%p) ", threadID); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + HIDE_OLD_TROUBLE (env); + + threadObj = getThreadFromThreadID (env, threadID); + if ( ! threadObj ) /* Already reported with BROKEN */ + goto done; + + (*env)->CallVoidMethod (env, threadObj, thread_join_mth); + if (MAYBE_BROKEN (env, "Thread.join() failed")) + goto done; + + + (*env)->CallStaticVoidMethod + (env, runner_class, runner_deRegisterJoinable_mth, threadObj); + if (MAYBE_BROKEN (env, "Thread.deRegisterJoinableThread() failed")) + goto done; + + SHOW_OLD_TROUBLE (); + +done: + DELETE_LOCAL_REF (env, threadObj); + if (TRACE_API_CALLS) + tracing (" ==> VOID \n"); +} + +/* Terminate the current thread. Unlike pthread_exit(), here we do not need + to bother with a return value or exit value for the thread which is about + to croak. (The gthreads abstraction doesn't use it.) However, we *do* + need to bail immediately. We handle this with Thread.stop(), which is + a deprecated method. + + It's deprecated since we might leave objects protected by monitors in + half-constructed states on the way out -- Thread.stop() throws a + ThreadDeath exception, which is usually unchecked. There is no good + solution that I can see. */ +static void +thread_exit_jni_impl (void) +{ + JNIEnv *env; + union env_union e; + jobject this_thread; + + if (TRACE_API_CALLS) + tracing ("thread_exit_jni_impl() "); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + goto done; + + HIDE_OLD_TROUBLE (env); + + this_thread = (*env)-> + CallStaticObjectMethod (env, thread_class, thread_current_mth); + + if ( ! this_thread ) + { + BROKEN (env, "cannot get current thread"); + goto done; + } + + (*env)->CallVoidMethod (env, this_thread, thread_stop_mth); + if (MAYBE_BROKEN (env, "cannot call Thread.stop() on current thread")) + goto done; + + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> VOID \n"); +} + + +/* Translate a GThreadPriority to a Java priority level. */ +static jint +javaPriorityLevel (GThreadPriority priority) +{ + /* We have these fields in java.lang.Thread to play with: + + static int MIN_PRIORITY The minimum priority that a thread can have. + static int NORM_PRIORITY The default priority that is assigned to a + thread. + static int MAX_PRIORITY The maximum priority that a thread can have. + + We get these from the header file generated by javah, even though they're + documented as being 1, 5, and 10. + */ + static const jint minJPri = + gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MIN_PRIORITY; + static const jint normJPri = + gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_NORM_PRIORITY; + static const jint maxJPri = + gnu_java_awt_peer_gtk_GThreadNativeMethodRunner_MAX_PRIORITY; + + switch (priority) + { + case G_THREAD_PRIORITY_LOW: + return minJPri; + break; + + default: + assert_not_reached (); + /* Deliberate fall-through if assertions are turned off; also shuts up + GCC warnings if they're turned on. */ + case G_THREAD_PRIORITY_NORMAL: + return normJPri; + break; + + case G_THREAD_PRIORITY_HIGH: + return (normJPri + maxJPri) / 2; + break; + + case G_THREAD_PRIORITY_URGENT: + return maxJPri; + break; + } +} + + +/** It would be safe not to implement this, according to the JNI docs, since + not all platforms do thread priorities. However, we might as well + provide the hint for those who want it. +*/ +static void +thread_set_priority_jni_impl (gpointer gThreadID, GThreadPriority gpriority) +{ + jobject threadObj = NULL; + JNIEnv *env; + union env_union e; + + if (TRACE_API_CALLS) + tracing ("thread_set_priority_jni_impl(gThreadID=%p, gpriority = %u) ", + gThreadID, gpriority); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + + if (setup_cache (env) < 0) + goto done; + + HIDE_OLD_TROUBLE (env); + + + threadObj = getThreadFromThreadID (env, gThreadID); + if ( ! threadObj) /* Reported with BROKEN already. */ + goto done; + + if (threadObj_set_priority (env, threadObj, gpriority)) + goto done; + + SHOW_OLD_TROUBLE (); + +done: + DELETE_LOCAL_REF (env, threadObj); + + if (TRACE_API_CALLS) + tracing (" ==> VOID\n"); +} + + +/** It would be safe not to implement this, according to the JNI docs, since + not all platforms do thread priorities. However, we might as well + provide the hint for those who want it. + + -1 on failure, 0 on success. */ +static int +threadObj_set_priority (JNIEnv * env, jobject threadObj, + GThreadPriority gpriority) +{ + jint javaPriority = javaPriorityLevel (gpriority); + (*env)->CallVoidMethod (env, threadObj, thread_setPriority_mth, + javaPriority); + return MAYBE_BROKEN (env, "Thread.setPriority() failed"); +} - (*gdk_vm)->GetEnv(gdk_vm, (void **)&gdk_env, JNI_VERSION_1_1); - int_class = (*gdk_env)->FindClass (gdk_env, "java.lang.Integer"); - MAYBE_RETHROW(gdk_env, "cannot find Integer"); +/** Return the result of Thread.currentThread(), a static method. */ +static void +thread_self_jni_impl (/* Another confusing glib prototype. This is + actually a gpointer to the thread's thread-ID. + Which is, of course, a gpointer. */ + gpointer my_thread_IDp) +{ + JNIEnv *env; + union env_union e; + jobject this_thread; + gpointer my_threadID; - new_int = (*gdk_env)->GetMethodID(gdk_env, int_class, "", "(I)V"); - MAYBE_RETHROW(gdk_env, "cannot find Integer."); + if (TRACE_API_CALLS) + tracing ("thread_self_jni_impl(my_thread_IDp=%p)", my_thread_IDp); - lcl_obj = (*gdk_env)->NewObject(gdk_env, int_class, new_int, (jint)data); - MAYBE_RETHROW(gdk_env, "cannot create an Integer"); + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); - lcl_class = (*gdk_env)->FindClass (gdk_env, "java.lang.ThreadLocal"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal"); + if (setup_cache (env) < 0) + return; - set_mth = (*gdk_env)->GetMethodID(gdk_env, lcl_class, "set", "(Ljava/lang/Object;)V"); - MAYBE_RETHROW(gdk_env, "cannot find ThreadLocal."); + HIDE_OLD_TROUBLE (env); - (*gdk_env)->CallVoidMethod(gdk_env, *(jobject*)private, set_mth, lcl_obj); - MAYBE_RETHROW(gdk_env, "cannot set thread local value"); + this_thread = (*env)-> + CallStaticObjectMethod (env, thread_class, thread_current_mth); + if (! this_thread ) + { + BROKEN (env, "cannot get current thread"); + my_threadID = NULL; + goto done; + } + + my_threadID = getThreadIDFromThread (env, this_thread); + SHOW_OLD_TROUBLE (); + +done: + if (TRACE_API_CALLS) + tracing (" ==> (my_threadID = %p) \n", my_threadID); + + *(gpointer *) my_thread_IDp = my_threadID; } +static gboolean +thread_equal_jni_impl (gpointer thread1, gpointer thread2) +{ + JNIEnv *env; + union env_union e; + + gpointer threadID1 = *(gpointer *) thread1; + gpointer threadID2 = *(gpointer *) thread2; + + jobject thread1_obj = NULL; + jobject thread2_obj = NULL; + gboolean ret; + + if (TRACE_API_CALLS) + tracing ("thread_equal_jni_impl(threadID1=%p, threadID2=%p)", + threadID1, threadID2); + + e.jni_env = &env; + (*the_vm)->GetEnv (the_vm, e.void_env, JNI_VERSION_1_1); + if (setup_cache (env) < 0) + { + ret = FALSE; /* what is safer? We really don't ever want + to return from here. */ + goto done; + } + + HIDE_OLD_TROUBLE (env); + thread1_obj = getThreadFromThreadID (env, threadID1); + thread2_obj = getThreadFromThreadID (env, threadID2); + + ret = (*env)->CallBooleanMethod (env, thread1_obj, + thread_equals_mth, thread2_obj); + + if (MAYBE_BROKEN (env, "Thread.equals() failed")) + { + ret = FALSE; + goto done; + } + + SHOW_OLD_TROUBLE (); + + +done: + DELETE_LOCAL_REF (env, thread1_obj); + DELETE_LOCAL_REF (env, thread2_obj); + + if (TRACE_API_CALLS) + tracing (" ==> %s\n", ret ? "TRUE" : "FALSE"); + + return ret; +} + + + + /************************************************************************/ /* GLIB interface */ /************************************************************************/ /* set of function pointers to give to glib. */ -GThreadFunctions g_thread_jni_functions = -{ - g_mutex_new_jni_impl, /* mutex_new */ - g_mutex_lock_jni_impl, /* mutex_lock */ - g_mutex_trylock_jni_impl, /* mutex_try_lock */ - g_mutex_unlock_jni_impl, /* mutex_unlock */ - g_mutex_free_jni_impl, /* mutex_free */ - g_cond_new_jni_impl, /* cond_new */ - g_cond_signal_jni_impl, /* cond_signal */ - g_cond_broadcast_jni_impl, /* cond_broadcast */ - g_cond_wait_jni_impl, /* cond_wait */ - g_cond_timed_wait_jni_impl, /* cond_timed_wait */ - g_cond_free_jni_impl, /* cond_free */ - g_private_new_jni_impl, /* private_new */ - g_private_get_jni_impl, /* private_get */ - g_private_set_jni_impl, /* private_set */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL +GThreadFunctions portable_native_sync_jni_functions = { + mutex_new_jni_impl, /* mutex_new */ + mutex_lock_jni_impl, /* mutex_lock */ + mutex_trylock_jni_impl, /* mutex_trylock */ + mutex_unlock_jni_impl, /* mutex_unlock */ + mutex_free_jni_impl, /* mutex_free */ + cond_new_jni_impl, /* cond_new */ + cond_signal_jni_impl, /* cond_signal */ + cond_broadcast_jni_impl, /* cond_broadcast */ + cond_wait_jni_impl, /* cond_wait */ + cond_timed_wait_jni_impl, /* cond_timed_wait */ + cond_free_jni_impl, /* cond_free */ + private_new_jni_impl, /* private_new */ + private_get_jni_impl, /* private_get */ + private_set_jni_impl, /* private_set */ + thread_create_jni_impl, /* thread_create */ + thread_yield_jni_impl, /* thread_yield */ + thread_join_jni_impl, /* thread_join */ + thread_exit_jni_impl, /* thread_exit */ + thread_set_priority_jni_impl, /* thread_set_priority */ + thread_self_jni_impl, /* thread_self */ + thread_equal_jni_impl, /* thread_equal */ }; - + + +/* Keep c-font-lock-extra-types in alphabetical order. */ +/* Local Variables: */ +/* c-file-style: "gnu" */ +/* c-font-lock-extra-types: ("\\sw+_t" "gboolean" "GError" "gpointer" + "GPrivate" "GThreadFunc" "GThreadFunctions" "GThreadPriority" + "gulong" + "JNIEnv" + "jboolean" "jclass" "jfieldID" "jint" "jlong" "jmethodID" "jobject" "jstring" "jthrowable" ) */ +/* End: */ diff --git a/libjava/jni/gtk-peer/gthread-jni.h b/libjava/jni/gtk-peer/gthread-jni.h index a0d093dccc8..90a252fa5c0 100644 --- a/libjava/jni/gtk-peer/gthread-jni.h +++ b/libjava/jni/gtk-peer/gthread-jni.h @@ -42,7 +42,7 @@ exception statement from your version. */ #include #include "gtkpeer.h" -extern GThreadFunctions g_thread_jni_functions; -extern JavaVM *gdk_vm; +extern GThreadFunctions portable_native_sync_jni_functions; +extern JavaVM *the_vm; #endif /* __GTHREADJNI_H__ */ diff --git a/libjava/jni/gtk-peer/gtkpeer.h b/libjava/jni/gtk-peer/gtkpeer.h index 18c95102472..59d49cedadc 100644 --- a/libjava/jni/gtk-peer/gtkpeer.h +++ b/libjava/jni/gtk-peer/gtkpeer.h @@ -91,6 +91,20 @@ extern struct state_table *native_global_ref_table; (*env)->DeleteGlobalRef (env, *globRefPtr); \ free (globRefPtr);} while (0) +extern struct state_table *native_pixbufdecoder_state_table; + +#define NSA_PB_INIT(env, clazz) \ + native_pixbufdecoder_state_table = init_state_table (env, clazz) + +#define NSA_GET_PB_PTR(env, obj) \ + get_state (env, obj, native_pixbufdecoder_state_table) + +#define NSA_SET_PB_PTR(env, obj, ptr) \ + set_state (env, obj, native_pixbufdecoder_state_table, (void *)ptr) + +#define NSA_DEL_PB_PTR(env, obj) \ + remove_state_slot (env, obj, native_pixbufdecoder_state_table) + #endif /* JVM_SUN */ struct graphics @@ -118,14 +132,14 @@ struct graphics #define SYNTHETIC_EVENT_MASK (1 << 10) -#define AWT_SHIFT_MASK (1 << 0) -#define AWT_CTRL_MASK (1 << 1) -#define AWT_META_MASK (1 << 2) -#define AWT_ALT_MASK (1 << 3) +#define AWT_SHIFT_DOWN_MASK (1 << 6) +#define AWT_CTRL_DOWN_MASK (1 << 7) +#define AWT_META_DOWN_MASK (1 << 8) +#define AWT_ALT_DOWN_MASK (1 << 9) -#define AWT_BUTTON1_MASK (1 << 4) -#define AWT_BUTTON2_MASK AWT_ALT_MASK -#define AWT_BUTTON3_MASK AWT_META_MASK +#define AWT_BUTTON1_DOWN_MASK (1 << 10) +#define AWT_BUTTON2_DOWN_MASK (1 << 11) +#define AWT_BUTTON3_DOWN_MASK (1 << 12) #define MULTI_CLICK_TIME 250 /* as opposed to a MULTI_PASS_TIME :) */ @@ -459,4 +473,19 @@ struct item_event_hook_info const char *label; }; +#define DEBUG_LOCKING 0 + +#if DEBUG_LOCKING +#define gdk_threads_enter() \ +{ \ + g_print ("lock: %s, %d\n", __FILE__, __LINE__); \ + gdk_threads_enter (); \ +} +#define gdk_threads_leave() \ +{ \ + g_print ("unlock: %s, %d\n", __FILE__, __LINE__); \ + gdk_threads_leave (); \ +} +#endif + #endif /* __GTKPEER_H */