/[classpath]/classpath/javax/swing/text/DefaultStyledDocument.java
ViewVC logotype

Diff of /classpath/javax/swing/text/DefaultStyledDocument.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by abalkiss, Fri Nov 4 22:50:03 2005 UTC revision 1.17 by abalkiss, Tue Nov 8 16:43:29 2005 UTC
# Line 772  public class DefaultStyledDocument exten Line 772  public class DefaultStyledDocument exten
772          }          }
773        offset += len;        offset += len;
774      }      }
775        
776        /**
777         * Creates a copy of the element <code>clonee</code> that has the parent
778         * <code>parent</code>.
779         * @param parent the parent of the newly created Element
780         * @param clonee the Element to clone
781         * @return the cloned Element
782         */
783        public Element clone (Element parent, Element clonee)
784        {
785          // If the Element we want to clone is a leaf, then simply copy it
786          if (clonee.isLeaf())
787            return createLeafElement(parent, clonee.getAttributes(),
788                                     clonee.getStartOffset(), clonee.getEndOffset());
789          
790          // Otherwise create a new BranchElement with the desired parent and
791          // the clonee's attributes
792          BranchElement result = (BranchElement) createBranchElement(parent, clonee.getAttributes());
793          
794          // And clone all the of clonee's children
795          Element[] children = new Element[clonee.getElementCount()];
796          for (int i = 0; i < children.length; i++)
797            children[i] = clone(result, clonee.getElement(i));
798          
799          // Make the cloned children the children of the BranchElement
800          result.replace(0, 0, children);
801          return result;
802        }
803    }    }
804    
805    /**    /**

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26