[jsword-svn] common/java/swing/org/crosswire/common/swing s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sat Oct 2 16:50:55 MST 2004


Update of /cvs/jsword/common/java/swing/org/crosswire/common/swing
In directory www.crosswire.org:/tmp/cvs-serv19597/java/swing/org/crosswire/common/swing

Modified Files:
	ActionFactory.java 
Added Files:
	AntiAliasedTextPane.java 
Log Message:
advanced search and a-a option.

Index: ActionFactory.java
===================================================================
RCS file: /cvs/jsword/common/java/swing/org/crosswire/common/swing/ActionFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ActionFactory.java	21 Sep 2004 17:45:47 -0000	1.9
--- ActionFactory.java	2 Oct 2004 23:50:52 -0000	1.10
***************
*** 82,89 ****
          // Instead of cascading if/then/else
          // use reflecton to do a direct lookup and call
          try
          {
-             String methodName = METHOD_PREFIX + action;
- 
              try
              {
--- 82,88 ----
          // Instead of cascading if/then/else
          // use reflecton to do a direct lookup and call
+         String methodName = METHOD_PREFIX + action;
          try
          {
              try
              {
***************
*** 99,103 ****
          catch (Exception ex)
          {
!             log.error(UNEXPECTED_ERROR, ex);
          }
      }
--- 98,102 ----
          catch (Exception ex)
          {
!             log.error("Could not execute method " + bean.getClass().getName() + "." + methodName + "()", ex); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          }
      }
***************
*** 111,116 ****
      {
          Action action = (CWAction) actions.get(key);
!         assert action != null : "Missing key: " + key; //$NON-NLS-1$
!         return action;
      }
  
--- 110,133 ----
      {
          Action action = (CWAction) actions.get(key);
! 
!         if (action != null)
!         {
!             return action;
!         }
!         else
!         {
!             log.info("Missing key: '" + key + "'. Known keys are: "+StringUtil.join(actions.keySet().toArray(), ", ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
!             assert false;
! 
!             CWAction getOutOfJailFreeAction = new CWAction();
! 
!             getOutOfJailFreeAction.putValue(Action.NAME, key);
!             getOutOfJailFreeAction.putValue(Action.SHORT_DESCRIPTION, MISSING_RESOURCE);
!             getOutOfJailFreeAction.putValue(Action.LONG_DESCRIPTION, MISSING_RESOURCE);
!             getOutOfJailFreeAction.setEnabled(true);
!             getOutOfJailFreeAction.addActionListener(this);
! 
!             return getOutOfJailFreeAction;
!         }
      }
  
***************
*** 393,397 ****
      }
  
!     private static final String UNEXPECTED_ERROR = "Stupid Programmer Error"; //$NON-NLS-1$
      private static final String METHOD_PREFIX = "do"; //$NON-NLS-1$
  
--- 410,422 ----
      }
  
!     /**
!      * The tooltip for actions that we generate to paper around missing resources
!      * Normally we would assert, but in live we might want to limp on.
!      */
!     private static final String MISSING_RESOURCE = "Missing Resource"; //$NON-NLS-1$
! 
!     /**
!      * The prefix to methods that we call
!      */
      private static final String METHOD_PREFIX = "do"; //$NON-NLS-1$
  

--- NEW FILE: AntiAliasedTextPane.java ---
package org.crosswire.common.swing;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JTextPane;

/**
 * An extension of JTextPane that does Anti-Aliasing.
 * J2SE5(joe): we will need to take a bit of care not clashing with J2SE5 AA
 * 
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 *
 * Distribution Licence:<br />
 * JSword is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.<br />
 * This program 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.<br />
 * The License is available on the internet
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA<br />
 * The copyright to this program is held by it's authors.
 * </font></td></tr></table>
 * @see gnu.gpl.Licence
 * @author Joe Walker [joe at eireneh dot com]
 * @version $Id: AntiAliasedTextPane.java,v 1.1 2004/10/02 23:50:52 joe Exp $
 */
public class AntiAliasedTextPane extends JTextPane
{
    /* (non-Javadoc)
     * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
     */
    public void paintComponent(Graphics g)
    {
        Graphics2D g2 = (Graphics2D) g;

        if (antiAliasing)
        {
            g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        }

        super.paintComponent(g2);
    }

    /**
     * @return Returns the anti aliasing status.
     */
    public static boolean isAntiAliasing()
    {
        return antiAliasing;
    }

    /**
     * @param antiAliasing The new anti aliasing status.
     */
    public static void setAntiAliasing(boolean antiAliasing)
    {
        AntiAliasedTextPane.antiAliasing = antiAliasing;
    }

    /**
     * Do we anti-alias the text box?
     */
    private static boolean antiAliasing = false;
}



More information about the jsword-svn mailing list