cvs commit: xml-fop/src/org/apache/fop/util CharUtilities.java StreamUtilities.java

2003-03-07 Thread jeremias
jeremias2003/03/07 02:09:50

  Modified:src/org/apache/fop/util CharUtilities.java
StreamUtilities.java
  Log:
  Switched to long licence
  Some general checkstyle fixing
  
  Revision  ChangesPath
  1.6   +49 -6 xml-fop/src/org/apache/fop/util/CharUtilities.java
  
  Index: CharUtilities.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/util/CharUtilities.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CharUtilities.java8 Jan 2003 14:05:11 -   1.5
  +++ CharUtilities.java7 Mar 2003 10:09:50 -   1.6
  @@ -1,10 +1,53 @@
   /*
* $Id$
  - * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  - * For details on use and redistribution please refer to the
  - * LICENSE file included with these sources.
  - */
  -
  + * 
  + *The Apache Software License, Version 1.1
  + * 
  + * 
  + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  + * 
  + * Redistribution and use in source and binary forms, with or without modifica-
  + * tion, are permitted provided that the following conditions are met:
  + * 
  + * 1. Redistributions of source code must retain the above copyright notice,
  + *this list of conditions and the following disclaimer.
  + * 
  + * 2. Redistributions in binary form must reproduce the above copyright notice,
  + *this list of conditions and the following disclaimer in the documentation
  + *and/or other materials provided with the distribution.
  + * 
  + * 3. The end-user documentation included with the redistribution, if any, must
  + *include the following acknowledgment: "This product includes software
  + *developed by the Apache Software Foundation (http://www.apache.org/)."
  + *Alternately, this acknowledgment may appear in the software itself, if
  + *and wherever such third-party acknowledgments normally appear.
  + * 
  + * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  + *endorse or promote products derived from this software without prior
  + *written permission. For written permission, please contact
  + *[EMAIL PROTECTED]
  + * 
  + * 5. Products derived from this software may not be called "Apache", nor may
  + *"Apache" appear in their name, without prior written permission of the
  + *Apache Software Foundation.
  + * 
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + * 
  + * 
  + * This software consists of voluntary contributions made by many individuals
  + * on behalf of the Apache Software Foundation and was originally created by
  + * James Tauber <[EMAIL PROTECTED]>. For more information on the Apache
  + * Software Foundation, please see .
  + */ 
   package org.apache.fop.util;
   
   import org.apache.fop.layout.FontState;
  
  
  
  1.3   +49 -5 xml-fop/src/org/apache/fop/util/StreamUtilities.java
  
  Index: StreamUtilities.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/util/StreamUtilities.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StreamUtilities.java  2 Dec 2002 14:15:08 -   1.2
  +++ StreamUtilities.java  7 Mar 2003 10:09:50 -   1.3
  @@ -1,9 +1,53 @@
   /*
* $Id$
  - * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
  - * For details on use and redistribution please refer to the
  - * LICENSE file included with these sources.
  - */
  + * 
  + *The Apache Software License, Version 1.1
  + * 
  + * 
  + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  + * 
  + * Redi

cvs commit: xml-fop/src/org/apache/fop/util CharUtilities.java

2003-01-08 Thread jeremias
jeremias2003/01/08 06:05:11

  Modified:src/org/apache/fop/util CharUtilities.java
  Log:
  Adjustments for font refactoring
  Lots of Javadocs
  Fixed Checkstyle errors
  
  Revision  ChangesPath
  1.5   +36 -10xml-fop/src/org/apache/fop/util/CharUtilities.java
  
  Index: CharUtilities.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/util/CharUtilities.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CharUtilities.java25 Oct 2002 09:29:48 -  1.4
  +++ CharUtilities.java8 Jan 2003 14:05:11 -   1.5
  @@ -1,6 +1,6 @@
   /*
* $Id$
  - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
  @@ -21,21 +21,38 @@
*/
   public static final char CODE_EOT = 0;
   
  -public static final int UCWHITESPACE = 0; // unicode white space
  +/**
  + * Character class: Unicode white space
  + */
  +public static final int UCWHITESPACE = 0;
  +/**
  + * Character class: Line feed
  + */
   public static final int LINEFEED = 1;
  -public static final int EOT = 2; // Boundary beteween text runs
  +/**
  + * Character class: Boundary between text runs
  + */
  +public static final int EOT = 2;
  +/**
  + * Character class: non-whitespace
  + */
   public static final int NONWHITESPACE = 3;
  +/**
  + * Character class: XML whitespace
  + */
   public static final int XMLWHITESPACE = 4;
   
   
   /**
* Return the appropriate CharClass constant for the type
* of the passed character.
  + * @param c character to inspect
  + * @return int the determined character class
*/
   public static int classOf(char c) {
   if (c == CODE_EOT) { return EOT; }
   if (c == '\n') { return LINEFEED; }
  -if (c == ' '|| c == '\r' || c == '\t' ) { return XMLWHITESPACE; }
  +if (c == ' ' || c == '\r' || c == '\t') { return XMLWHITESPACE; }
   if (isAnySpace(c)) { return UCWHITESPACE; }
   return NONWHITESPACE;
   }
  @@ -45,6 +62,9 @@
* from the current fontstate.
* This also performs some guessing on widths on various
* versions of space that might not exists in the font.
  + * @param c character to inspect
  + * @param fs FontState to use
  + * @return int the width of the character
*/
   public static int getCharWidth(char c, FontState fs) {
   int width;
  @@ -52,12 +72,12 @@
   if ((c == '\n') || (c == '\r') || (c == '\t') || (c == '\u00A0')) {
   width = getCharWidth(' ', fs);
   } else {
  -width = fs.width(fs.mapChar(c));
  +width = fs.getWidth(fs.mapChar(c));
   if (width <= 0) {
   // Estimate the width of spaces not represented in
   // the font
  -int em = fs.width(fs.mapChar('m'));
  -int en = fs.width(fs.mapChar('n'));
  +int em = fs.getWidth(fs.mapChar('m'));
  +int en = fs.getWidth(fs.mapChar('n'));
   if (em <= 0) {
   em = 500 * fs.getFontSize();
   }
  @@ -119,7 +139,9 @@
   /**
* Helper method to determine if the character is a
* space with normal behaviour. Normal behaviour means that
  - * it's not non-breaking
  + * it's not non-breaking.
  + * @param c character to inspect
  + * @return boolean True if the character is a normal space
*/
   public static boolean isSpace(char c) {
   return (c == ' '
  @@ -141,6 +163,8 @@
   /**
* Method to determine if the character is a nonbreaking
* space.
  + * @param c character to check
  + * @return boolean True if the character is a nbsp
*/
   public static boolean isNBSP(char c) {
   if (c == '\u00A0' || c == '\u202F'// narrow no-break space
  @@ -153,7 +177,9 @@
   }
   
   /**
  - * @return true if the character represents any kind of space
  + * Determines if the character represents any kind of space.
  + * @param c character to check
  + * @return True if the character represents any kind of space
*/
   public static boolean isAnySpace(char c) {
   boolean ret = (isSpace(c) || isNBSP(c));
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-fop/src/org/apache/fop/util CharUtilities.java

2002-02-25 Thread klease

klease  02/02/25 13:28:28

  Modified:src/org/apache/fop/util CharUtilities.java
  Log:
  Use CharUtilities instead of CharClass
  
  Revision  ChangesPath
  1.2   +42 -16xml-fop/src/org/apache/fop/util/CharUtilities.java
  
  Index: CharUtilities.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/util/CharUtilities.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharUtilities.java8 Jan 2002 11:03:07 -   1.1
  +++ CharUtilities.java25 Feb 2002 21:28:28 -  1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: CharUtilities.java,v 1.1 2002/01/08 11:03:07 keiron Exp $
  + * $Id: CharUtilities.java,v 1.2 2002/02/25 21:28:28 klease Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
  @@ -10,9 +10,36 @@
   import org.apache.fop.layout.FontState;
   
   /**
  + * This class provides utilities to distinguish various kinds of Unicode
  + * whitespace and to get character widths in a given FontState.
*/
   public class CharUtilities {
   
  +/** Character code used to signal a character boundary in
  + * inline content, such as an inline with borders and padding
  + * or a nested block object.
  + */
  +public static final char CODE_EOT=0;
  +
  +public static final int UCWHITESPACE=0; // unicode white space
  +public static final int LINEFEED=1;
  +public static final int EOT=2; // Boundary beteween text runs
  +public static final int NONWHITESPACE=3;
  +public static final int XMLWHITESPACE=4;
  +
  +
  +/**
  + * Return the appropriate CharClass constant for the type
  + * of the passed character.
  + */
  +public static int classOf(char c) {
  + if (c == CODE_EOT) return EOT;
  + if (c == '\n') return LINEFEED;
  + if ( c==' '|| c == '\r' || c=='\t' ) return XMLWHITESPACE;
  + if (isAnySpace(c)) return UCWHITESPACE;
  + return NONWHITESPACE;
  +}
  +
   /**
* Helper method for getting the width of a unicode char
* from the current fontstate.
  @@ -76,21 +103,20 @@
* it's not non-breaking
*/
   public static boolean isSpace(char c) {
  -if (c == ' ' || c == '\u2000' ||// en quad
  -c == '\u2001' ||// em quad
  -c == '\u2002' ||// en space
  -c == '\u2003' ||// em space
  -c == '\u2004' ||// three-per-em space
  -c == '\u2005' ||// four--per-em space
  -c == '\u2006' ||// six-per-em space
  -c == '\u2007' ||// figure space
  -c == '\u2008' ||// punctuation space
  -c == '\u2009' ||// thin space
  -c == '\u200A' ||// hair space
  -c == '\u200B')  // zero width space
  -return true;
  -else
  -return false;
  +return (c == ' ' ||
  + (c >= '\u2000' && c <= '\u200B'));
  +// c == '\u2000'   // en quad
  +// c == '\u2001'   // em quad
  +// c == '\u2002'   // en space
  +// c == '\u2003'   // em space
  +// c == '\u2004'   // three-per-em space
  +// c == '\u2005'   // four--per-em space
  +// c == '\u2006'   // six-per-em space
  +// c == '\u2007'   // figure space
  +// c == '\u2008'   // punctuation space
  +// c == '\u2009'   // thin space
  +// c == '\u200A'   // hair space
  +// c == '\u200B'   // zero width space
   }
   
   /**
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-fop/src/org/apache/fop/util CharUtilities.java

2002-01-08 Thread keiron

keiron  02/01/08 03:03:07

  Added:   src/org/apache/fop/util CharUtilities.java
  Log:
  utils for characters such as getting width and determining if space
  
  Revision  ChangesPath
  1.1  xml-fop/src/org/apache/fop/util/CharUtilities.java
  
  Index: CharUtilities.java
  ===
  /*
   * $Id: CharUtilities.java,v 1.1 2002/01/08 11:03:07 keiron Exp $
   * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
   * For details on use and redistribution please refer to the
   * LICENSE file included with these sources.
   */
  
  package org.apache.fop.util;
  
  import org.apache.fop.layout.FontState;
  
  /**
   */
  public class CharUtilities {
  
  /**
   * Helper method for getting the width of a unicode char
   * from the current fontstate.
   * This also performs some guessing on widths on various
   * versions of space that might not exists in the font.
   */
  public static int getCharWidth(char c, FontState fs) {
  int width = fs.width(fs.mapChar(c));
  if (width <= 0) {
  // Estimate the width of spaces not represented in
  // the font
  int em = fs.width(fs.mapChar('m'));
  int en = fs.width(fs.mapChar('n'));
  if (em <= 0)
  em = 500 * fs.getFontSize();
  if (en <= 0)
  en = em - 10;
  
  if (c == ' ')
  width = em;
  if (c == '\u2000')
  width = en;
  if (c == '\u2001')
  width = em;
  if (c == '\u2002')
  width = em / 2;
  if (c == '\u2003')
  width = fs.getFontSize();
  if (c == '\u2004')
  width = em / 3;
  if (c == '\u2005')
  width = em / 4;
  if (c == '\u2006')
  width = em / 6;
  if (c == '\u2007')
  width = getCharWidth(' ', fs);
  if (c == '\u2008')
  width = getCharWidth('.', fs);
  if (c == '\u2009')
  width = em / 5;
  if (c == '\u200A')
  width = 5;
  if (c == '\u200B')
  width = 100;
  if (c == '\u00A0')
  width = getCharWidth(' ', fs);
  if (c == '\u202F')
  width = getCharWidth(' ', fs) / 2;
  if (c == '\u3000')
  width = getCharWidth(' ', fs) * 2;
  if ((c == '\n') || (c == '\r') || (c == '\t'))
  width = getCharWidth(' ', fs);
  }
  
  return width;
  }
  
  /**
   * Helper method to determine if the character is a
   * space with normal behaviour. Normal behaviour means that
   * it's not non-breaking
   */
  public static boolean isSpace(char c) {
  if (c == ' ' || c == '\u2000' ||// en quad
  c == '\u2001' ||// em quad
  c == '\u2002' ||// en space
  c == '\u2003' ||// em space
  c == '\u2004' ||// three-per-em space
  c == '\u2005' ||// four--per-em space
  c == '\u2006' ||// six-per-em space
  c == '\u2007' ||// figure space
  c == '\u2008' ||// punctuation space
  c == '\u2009' ||// thin space
  c == '\u200A' ||// hair space
  c == '\u200B')  // zero width space
  return true;
  else
  return false;
  }
  
  /**
   * Method to determine if the character is a nonbreaking
   * space.
   */
  public static boolean isNBSP(char c) {
  if (c == '\u00A0' || c == '\u202F' ||// narrow no-break space
  c == '\u3000' ||// ideographic space
  c == '\uFEFF') {// zero width no-break space
  return true;
  } else
  return false;
  }
  
  /**
   * @return true if the character represents any kind of space
   */
  public static boolean isAnySpace(char c) {
  boolean ret = (isSpace(c) || isNBSP(c));
  return ret;
  }
  }
  
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]