[cp-patches] FYI: Insertion methods for the HTMLDocument
This patch implements the insertion methods (insertAfterEnd, insertBeforeEnd, insertAfterStart, insertBeforeStart, setInnerHTML and SetOuterHTML). I also extended our demo to make the debugging of these methods easier. 2006-07-13 Audrius Meskauskas [EMAIL PROTECTED] * javax/swing/text/html/HTMLDocument.java (HTMLReader.parseStack): Made package private. (HTMLReader.charAttr, HTMLReader.charAttrStack, HTMLReader.insertTag, HTMLReader.insertTagEncountered, HTMLReader.pushDepth, HTMLReader.popDepth): Documented. (HRMLReader.blockClose): Mind that parser stack may be empty. (HTMLReader.handeComment, HTMLReader.handleStartTag, HTMLReader.handleEndTag, HTMLReader.handleSimpleTag): Rewritten. (HTMLReader.shouldInsert): New method. (getElement(String)): Pass HTML.Atrribute.ID. (insertAfterEnd, insertBeforeEnd, insertAfterStart, insertBeforeStart, setInnerHTML, SetOuterHTML): Implemented. (getInsertingReader): New method. * examples/gnu/classpath/examples/swing/HtmlDemo.java: Added buttons to demonstrate the work of the insert actions. Index: examples/gnu/classpath/examples/swing/HtmlDemo.java === RCS file: /sources/classpath/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java,v retrieving revision 1.2 diff -u -r1.2 HtmlDemo.java --- examples/gnu/classpath/examples/swing/HtmlDemo.java 8 Jul 2006 19:46:45 - 1.2 +++ examples/gnu/classpath/examples/swing/HtmlDemo.java 13 Jul 2006 12:17:26 - @@ -52,6 +52,8 @@ import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.SwingUtilities; +import javax.swing.text.Element; +import javax.swing.text.html.HTMLDocument; /** * Parses and displays HTML content. @@ -66,11 +68,14 @@ JTextArea text = new JTextArea(htmlbodyp + 123456789HR!hr987654321+ 123456789BR!br987654321+ +p id='insertHere'Insertion target/pp+ font color=redma/font+ supsup/supnormalsubsub/subnormal/ppTable:+ tabletratdbtdctrxtdytdz/table/body/html); JPanel buttons; + + int n; public HtmlDemo() { @@ -111,7 +116,131 @@ }); buttons.add(parse); + +JButton insertBeforeEnd = new JButton(before end); +insertBeforeEnd.addActionListener(new ActionListener() + { +public void actionPerformed(ActionEvent event) + { +HTMLDocument doc = (HTMLDocument) html.getDocument(); +Element el = doc.getElement(insertHere); +System.out.println(Element found:+el); +try + { +doc.insertBeforeEnd(el,before end +(n++)); + } +catch (Exception e) + { +e.printStackTrace(); + } + } + }); + +JButton insertBeforeStart = new JButton(before start); +insertBeforeStart.addActionListener(new ActionListener() + { +public void actionPerformed(ActionEvent event) + { +HTMLDocument doc = (HTMLDocument) html.getDocument(); +Element el = doc.getElement(insertHere); +System.out.println(Element found:+el); +try + { +doc.insertBeforeStart(el,before start +(n++)); + } +catch (Exception e) + { +e.printStackTrace(); + } + } + }); + +JButton insertAfterEnd = new JButton(after end); +insertAfterEnd.addActionListener(new ActionListener() + { +public void actionPerformed(ActionEvent event) + { +HTMLDocument doc = (HTMLDocument) html.getDocument(); +Element el = doc.getElement(insertHere); +System.out.println(Element found:+el); +try + { +doc.insertAfterEnd(el,after end +(n++)); + } +catch (Exception e) + { +e.printStackTrace(); + } + } + }); + +JButton insertAfterStart = new JButton(after start); +insertAfterStart.addActionListener(new ActionListener() + { +public void actionPerformed(ActionEvent event) + { +HTMLDocument doc = (HTMLDocument) html.getDocument(); +Element el = doc.getElement(insertHere); +System.out.println(Element found:+el); +try + { +doc.insertAfterStart(el,after start +(n++)); + } +catch (Exception e) + { +e.printStackTrace(); + } + } + }); + + +JButton setInner = new JButton(inner); +setInner.addActionListener(new ActionListener() + { +public void actionPerformed(ActionEvent event) + { +HTMLDocument doc = (HTMLDocument) html.getDocument(); +Element el = doc.getElement(insertHere); +
[cp-patches] FYI: BandedSampleModel - updated API docs
This patch (committed) updates the API docs for the BandedSampleModel class: 2006-07-13 David Gilbert [EMAIL PROTECTED] * java/awt/image/BandedSampleModel.java: API doc updates. Regards, Dave Index: java/awt/image/BandedSampleModel.java === RCS file: /sources/classpath/classpath/java/awt/image/BandedSampleModel.java,v retrieving revision 1.5 diff -u -r1.5 BandedSampleModel.java --- java/awt/image/BandedSampleModel.java 2 Jul 2005 20:32:29 - 1.5 +++ java/awt/image/BandedSampleModel.java 13 Jul 2006 13:20:48 - @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, Free Software Foundation +/* Copyright (C) 2004, 2005, 2006, Free Software Foundation This file is part of GNU Classpath. @@ -61,17 +61,45 @@ return result; } + /** + * Creates a new codeBandedSampleModel/code. + * + * @param dataType the data buffer type. + * @param w the width (in pixels). + * @param h the height (in pixels). + * @param numBands the number of bands. + */ public BandedSampleModel(int dataType, int w, int h, int numBands) { this(dataType, w, h, w, createBankArray(numBands), new int[numBands]); } + /** + * Creates a new codeBandedSampleModel/code. + * + * @param dataType the data buffer type. + * @param w the width (in pixels). + * @param h the height (in pixels). + * @param scanlineStride the number of data elements from a pixel in one + * row to the corresponding pixel in the next row. + * @param bankIndices the bank indices. + * @param bandOffsets the band offsets. + */ public BandedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets) { super(dataType, w, h, 1, scanlineStride, bankIndices, bandOffsets); } + /** + * Creates a new codeSampleModel/code that is compatible with this + * model and has the specified width and height. + * + * @param w the width (in pixels). + * @param h the height (in pixels). + * + * @return The new sample model. + */ public SampleModel createCompatibleSampleModel(int w, int h) { // NOTE: blackdown 1.4.1 sets all offsets to 0. Sun's 1.4.2 docs @@ -195,6 +223,22 @@ } } + /** + * Returns all the samples for the pixel at location code(x, y)/code + * stored in the specified data buffer. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param iArray an array that will be populated with the sample values and + * returned as the result. The size of this array should be equal to the + * number of bands in the model. If the array is codenull/code, a new + * array is created. + * @param data the data buffer (codenull/code not permitted). + * + * @return The samples for the specified pixel. + * + * @see #setPixel(int, int, int[], DataBuffer) + */ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) { if (iArray == null) iArray = new int[numBands]; @@ -247,18 +291,64 @@ return iArray; } + /** + * Returns a sample value for the pixel at (x, y) in the specified data + * buffer. + * + * @param x the x-coordinate of the pixel. + * @param y the y-coordinate of the pixel. + * @param b the band (in the range code0/code to + * codegetNumBands() - 1/code). + * @param data the data buffer (codenull/code not permitted). + * + * @return The sample value. + * + * @throws NullPointerException if codedata/code is codenull/code. + */ public int getSample(int x, int y, int b, DataBuffer data) { int offset = bandOffsets[b] + y * scanlineStride + x; return data.getElem(bankIndices[b], offset); } + /** + * Returns a sample value for the pixel at (x, y) in the specified data + * buffer. + * + * @param x the x-coordinate of the pixel. + * @param y the y-coordinate of the pixel. + * @param b the band (in the range code0/code to + * codegetNumBands() - 1/code). + * @param data the data buffer (codenull/code not permitted). + * + * @return The sample value. + * + * @throws NullPointerException if codedata/code is codenull/code. + * + * @see #getSample(int, int, int, DataBuffer) + */ public float getSampleFloat(int x, int y, int b, DataBuffer data) { int offset = bandOffsets[b] + y * scanlineStride + x; return data.getElemFloat(bankIndices[b], offset); } + /** + * Returns the sample value for the pixel at (x, y) in the specified data + * buffer. + * + * @param x the x-coordinate of the pixel. + * @param y the y-coordinate of the pixel. + * @param b the band (in the range code0/code to + * codegetNumBands() - 1/code). + * @param data the data buffer (codenull/code not permitted). + * + * @return The sample value. + * + * @throws NullPointerException if
Re: [cp-patches] [RFA] JVMTI
Keith == Keith Seitz [EMAIL PROTECTED] writes: Keith The following patch adds jvmti.h to the classpath repository. It is Keith very closely modeled on jni.h. Looks great. Please check it in. Keith PS. Yes, I know there are about twenty-five lines (all function decls) Keith which are longer than eighty chars. Nonetheless I've decided to keep Keith them this way in order to maintain the same parameter list that the Keith JVMTI spec uses. If maintainers prefer some other formatting, just Keith notify me. I think that is fine. Tom
[cp-patches] FYI: Component/Container fixes
The attached patch fixes some issues with Container/Component wrt to the pref/min/max size: - Added proper locking of the tree. - Corrected handling of cached values. - Need to return copy of the real thing, so that apps can play tricks with the actual values. This causes no regressions in Mauve and Intel's testsuite, and actually fix Tania's new test for invalidate. 2006-07-13 Roman Kennke [EMAIL PROTECTED] * java/awt/Component.java (DEFAULT_MAX_SIZE): New static constant. (preferredSize): Return copy of the actual value computed by new helper method. (preferredSizeImpl): New helper method. Adds locking and correct handling of cached value. (minimumSize): Return copy of the actual value computed by new helper method. (minimumSizeImpl): New helper method. Adds locking and correct handling of cached value. (getMaximumSize): Return copy of the actual value computed by new helper method. (maximumSizeImpl): New helper method. Adds locking and correct handling of cached value. (invalidate): Correct handling of cached layout information. Added locking. * java/awt/Container.java (preferredSize): Minimized locking. Corrected handling of cached values. Return copy of real value. (minimumSize): Minimized locking. Corrected handling of cached values. Return copy of real value. (getMaximumSize): Minimized locking. Corrected handling of cached values. Return copy of real value. /Roman Index: java/awt/Component.java === RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v retrieving revision 1.132 diff -u -1 -2 -r1.132 Component.java --- java/awt/Component.java 7 Jul 2006 14:08:44 - 1.132 +++ java/awt/Component.java 13 Jul 2006 19:22:26 - @@ -205,24 +205,30 @@ * @see #getAlignmentX() */ public static final float LEFT_ALIGNMENT = 0; /** * Make the treelock a String so that it can easily be identified * in debug dumps. We clone the String in order to avoid a conflict in * the unlikely event that some other package uses exactly the same string * as a lock object. */ static final Object treeLock = new String(AWT_TREE_LOCK); + /** + * The default maximum size. + */ + private static final Dimension DEFAULT_MAX_SIZE + = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); + // Serialized fields from the serialization spec. /** * The x position of the component in the parent's coordinate system. * * @see #getLocation() * @serial the x position */ int x; /** * The y position of the component in the parent's coordinate system. @@ -1651,32 +1657,54 @@ { return prefSizeSet; } /** * Returns the component's preferred size. * * @return the component's preferred size * @deprecated use [EMAIL PROTECTED] #getPreferredSize()} instead */ public Dimension preferredSize() { -if (!prefSizeSet) +// Create a new Dimension object, so that the application doesn't mess +// with the actual values. +return new Dimension(preferredSizeImpl()); + } + + /** + * The actual calculation is pulled out of preferredSize() so that + * we can call it from Container.preferredSize() and avoid creating a + * new intermediate Dimension object. + * + * @return the preferredSize of the component + */ + Dimension preferredSizeImpl() + { +Dimension size = prefSize; +// Try to use a cached value. +if (size == null || !(valid || prefSizeSet)) { -if (peer == null) - prefSize = minimumSize(); -else - prefSize = peer.getPreferredSize(); +// We need to lock here, because the calculation depends on the +// component structure not changing. +synchronized (getTreeLock()) + { +ComponentPeer p = peer; +if (p != null) + size = peer.preferredSize(); +else + size = minimumSizeImpl(); + } } -return prefSize; +return size; } /** * Returns the component's minimum size. * * @return the component's minimum size * @see #getPreferredSize() * @see #setMinimumSize(Dimension) * @see LayoutManager */ public Dimension getMinimumSize() { @@ -1715,45 +1743,85 @@ { return minSizeSet; } /** * Returns the component's minimum size. * * @return the component's minimum size * @deprecated use [EMAIL PROTECTED] #getMinimumSize()} instead */ public Dimension minimumSize() { -if (minSize == null) - minSize = (peer != null ? peer.getMinimumSize() - : new Dimension(width, height)); -return minSize; +// Create a new Dimension object, so that the application
Re: [cp-patches] FYI: java.awt.GridBagLayout.AdjustForGravity
Mark Wielaard wrote: Hi Tom, On Sun, 2006-06-18 at 15:20 -0400, Thomas Fitzsimmons wrote: This implements the last missing 1.1 method, java.awt.GridBagLayout.AdjustForGravity. I committed a corresponding Mauve test. 2006-06-18 Thomas Fitzsimmons [EMAIL PROTECTED] * java/awt/GridBagLayout.java (AdjustForGravity): Implement. * java/awt/GridBagConstraints.java: Indent. Although it make the Mauve test happy it makes most JDialogs sad. See for example the Free Swing demo help - Really which VM... dialog. Reverting this patch makes all the text visible again. Could you investigate? We really cannot create a release branch unless we solve this since it impacts a large amount of applications. Darn, I didn't realize this was actually called from within GridBagLayout. For now, let's revert to Sven's version of the patch (to the detriment of the Mauve results, but to the benefit of JDialog) since I may not have time to look at this soon. Likely the problem is duplication of logic in AdjustForGravity and ArrangeGrid. Tom
Re: [cp-patches] RFC: java.lang.StrictMath#cbrt implemented
On Thu, 2006-07-13 at 19:46 +0200, Carsten Neumann wrote: Hi, the attached patch implements java.lang.StrictMath#cbrt, but I'm actually quite ashamed to post it: I'm not very knowledgeable about floating point arithmetic, so I just followed the implementation in fdlibm (www.netlib.org/fdlibm). Unfortunately this library does some weird manipulations of the bits of a double, which I simply mimicked in java. That's probably okay though. Actually it's probably a lot better coding practice to do it in Java than in C since Java at least has a strictly defined idea of what a double is. (A bigger problem with some VMs (*cough* GCJ) is that the internal representation of a double isn't right. E.g. the might use the processors extended 80-bit doubles *cough* instead of IEEE 64-bit ones) One question though.. would it make sense to use longs instead of int[2] for the 'word' stuff? You could use the Double.doubleFromRawLong method to convert back to double then. /Sven
Re: [cp-patches] RFC: java.lang.StrictMath#cbrt implemented
Carsten Neumann wrote: Here is an updated version. + * Returns the cube root of codex/code. The sign of the cube root + * is equal to the sign of the sign of codex/code. You've got an extra the sign of in there.. -Archie __ Archie Cobbs *CTO, Awarix* http://www.awarix.com
[cp-patches] FYI: GIFImageReader cleaning
2006-07-12 Sven de Marothy [EMAIL PROTECTED] * gnu/javax/imageio/gif/GIFImageReader.java (read): Remove old debugging trace. Index: gnu/javax/imageio/gif/GIFImageReader.java === RCS file: /sources/classpath/classpath/gnu/javax/imageio/gif/GIFImageReader.java,v retrieving revision 1.1 diff -U3 -r1.1 GIFImageReader.java --- gnu/javax/imageio/gif/GIFImageReader.java 26 Jun 2006 16:06:30 - 1.1 +++ gnu/javax/imageio/gif/GIFImageReader.java 13 Jul 2006 21:41:11 - @@ -231,9 +231,6 @@ new int[] {0xFF}); break; } -byte[] bits = f.getRawImage(); -for(int i = 0; i 5; i++) - System.out.println(Bits +i+:+bits[i]); DataBuffer db = new DataBufferByte(f.getRawImage(), width * height, 0); WritableRaster raster = Raster.createWritableRaster(sm, db, null);
[cp-patches] [patch] PR28369
Hello all, I'll commit this one asap. Thanks to Sven_M! This fixes PR 28369 on big and little endian platforms. Andreas 2006-07-13 Andreas Tobler [EMAIL PROTECTED] PR awt/28369: * gnu/java/awt/peer/gtk/CairoSurface.java (ColorModel): Swap red and blue mask. Index: gnu/java/awt/peer/gtk/CairoSurface.java === RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/CairoSurface.java,v retrieving revision 1.11 diff -u -r1.11 CairoSurface.java --- gnu/java/awt/peer/gtk/CairoSurface.java 28 Jun 2006 19:47:42 - 1.11 +++ gnu/java/awt/peer/gtk/CairoSurface.java 13 Jul 2006 21:39:00 - @@ -80,10 +80,10 @@ long bufferPointer; - static ColorModel nativeModel = new DirectColorModel(32, - 0x00FF, - 0xFF00, + static ColorModel nativeModel = new DirectColorModel(32, 0x00FF, + 0xFF00, + 0x00FF, 0xFF00); /**
Re: [cp-patches] FYI: Component/Container fixes
java.util.concurency provides the whole package just for lockings. It is possible to lock separately for reading and for writing. Maybe we could use these classes in the head? Audrius.
Re: [cp-patches] RFC: Clone fix for gnu.java.security.OID
Hi, On Wed, 2006-07-12 at 19:24 +0200, Mario Torre wrote: This patch is hopefully a fix for clone method in gnu.java.security.OID.java Can someone please comment on this? Maybe Casey knows more since he seems to have written the original. I'll just note that your implementation does copy the relative boolean field which the old code didn't do (I suspect that was a bug in the old code). 2006-07-12 Mario Torre [EMAIL PROTECTED] * gnu/java/security/OID.java (clone): Fixed. That is not a very good comment. What about: 'Implemented using super.clone()' to describe what you did? Cheers, Mark
Re: [cp-patches] FYI: Component/Container fixes
Audrius == Audrius Meskauskas [EMAIL PROTECTED] writes: Audrius java.util.concurency provides the whole package just for lockings. It Audrius is possible to lock separately for reading and for writing. Maybe we Audrius could use these classes in the head? Currently we only have these classes on the generics branch. Also, theses classes require VM support... I think right now only IKVM implements this. We should probably talk about merging the generics branch back to the trunk. Perhaps we ought to do it immediately after 0.92. Tom
[cp-patches] FIY: Clone fix for gnu.java.security.OID
Il giorno ven, 14/07/2006 alle 00.15 +0200, Mark Wielaard ha scritto: That is not a very good comment. What about: 'Implemented using super.clone()' to describe what you did? Cheers, Mark For some reason I have not the email from David Daney. But anyway, thanks for the reply, I have committed with this Changelog message (hope is better): 2006-07-14 Mario Torre [EMAIL PROTECTED] * gnu/java/security/OID.java (OID): Private Constructor removed as it is not needed anymore. (clone): Fixed. Now uses super.clone instead of the private constructor as per specification of clone method. (serialVersionUID): added new field to allow serialization. Mario -- Lima Software, SO.PR.IND. s.r.l. http://www.limasoftware.net/ pgp key: http://subkeys.pgp.net/ Please, support open standards: http://opendocumentfellowship.org/petition/ http://www.nosoftwarepatents.com/ === RCS file: /sources/classpath/classpath/gnu/java/security/OID.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- classpath/gnu/java/security/OID.java 2006/05/20 03:25:09 1.7 +++ classpath/gnu/java/security/OID.java 2006/07/13 23:29:28 1.8 @@ -71,6 +71,9 @@ // Fields. // + /* Serial version id for serialization. */ + static final long serialVersionUID = 5722492029044597779L; + /** * The numeric ID structure. */ @@ -229,13 +232,6 @@ } } - /** - * Our private constructor. - */ - private OID() - { - } - // Instance methods. // @@ -325,10 +321,16 @@ */ public Object clone() { -OID oid = new OID(); -oid.components = this.components; -oid.strRep = this.strRep; -return oid; +try + { +return super.clone(); + } +catch (CloneNotSupportedException cnse) + { +InternalError ie = new InternalError(); +ie.initCause(cnse); +throw ie; + } } /* Nice idea, but possibly too expensive for whatever benefit it signature.asc Description: Questa รจ una parte del messaggio firmata digitalmente
Re: [cp-patches] RFC: Clone fix for gnu.java.security.OID
On Jul 13, 2006, at 3:15 PM, Mark Wielaard wrote: Hi, On Wed, 2006-07-12 at 19:24 +0200, Mario Torre wrote: This patch is hopefully a fix for clone method in gnu.java.security.OID.java Can someone please comment on this? Maybe Casey knows more since he seems to have written the original. I'll just note that your implementation does copy the relative boolean field which the old code didn't do (I suspect that was a bug in the old code). Yeah, using `Object.clone()' is the preferred approach. Using it in OID is correct. PGP.sig Description: This is a digitally signed message part