001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.visualweb.text;
042:
043: import javax.swing.UIManager;
044:
045: import javax.swing.plaf.ComponentUI;
046:
047: import org.netbeans.modules.visualweb.api.designer.DomProvider.DomPosition;
048:
049: /**
050: * Text editor user interface
051: *
052: * @author Timothy Prinzing
053: * @version 1.31 01/23/03
054: */
055: public abstract class DesignerPaneBaseUI extends ComponentUI {
056: // /**
057: // * Converts the given location in the model to a place in
058: // * the view coordinate system.
059: // *
060: // * @param pos the local location in the model to translate >= 0
061: // * @return the coordinates as a rectangle
062: // * @exception BadLocationException if the given position does not
063: // * represent a valid location in the associated document
064: // */
065: // public abstract Rectangle modelToView(/*DesignerPaneBase t,*/ Position pos);
066: //
067: // /**
068: // * Converts the given place in the view coordinate system
069: // * to the nearest representative location in the model.
070: // *
071: // * @param pt the location in the view to translate. This
072: // * should be in the same coordinate system as the mouse
073: // * events.
074: // * @return the offset from the start of the document >= 0
075: // */
076: // public abstract Position viewToModel(DesignerPaneBase t, Point pt);
077:
078: /**
079: * Provides a way to determine the next visually represented model
080: * location that one might place a caret. Some views may not be visible,
081: * they might not be in the same order found in the model, or they just
082: * might not allow access to some of the locations in the model.
083: *
084: * @param pos the position to convert >= 0
085: * @param a the allocated region to render into
086: * @param direction the direction from the current position that can
087: * be thought of as the arrow keys typically found on a keyboard.
088: * This may be SwingConstants.WEST, SwingConstants.EAST,
089: * SwingConstants.NORTH, or SwingConstants.SOUTH.
090: * @return the location within the model that best represents the next
091: * location visual position.
092: * @exception BadLocationException
093: * @exception IllegalArgumentException for an invalid direction
094: */
095: // public abstract Position getNextVisualPositionFrom(DesignerPaneBase t, Position pos,
096: // int direction);
097: public abstract DomPosition getNextVisualPositionFrom(
098: DesignerPaneBase t, DomPosition pos, int direction);
099:
100: /**
101: * Fetches the name used as a key to lookup properties through the
102: * UIManager. This is used as a prefix to all the standard
103: * text properties.
104: *
105: * @return the name ("EditorPane")
106: */
107: protected abstract String getPropertyPrefix();
108:
109: /**
110: * Creates the object to use for a caret. By default an
111: * instance of BasicCaret is created. This method
112: * can be redefined to provide something else that implements
113: * the InputPosition interface or a subclass of JCaret.
114: *
115: * @return the caret object
116: */
117: protected DesignerCaret createCaret() {
118: DesignerCaret caret = new DesignerCaret();
119:
120: String prefix = getPropertyPrefix();
121: Object o = UIManager.get(prefix + ".caretBlinkRate"); // NOI18N
122:
123: if ((o != null) && (o instanceof Integer)) {
124: Integer rate = (Integer) o;
125: caret.setBlinkRate(rate.intValue());
126: }
127:
128: return caret;
129: }
130:
131: }
|