/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A collection of utility methods for Swing.
* <p>
* <b>WARNING:</b> While this class is public, it should not be treated as
* public API and its API may change in incompatable ways between dot dot
* releases and even patch releases. You should not rely on this class even
* existing.
*
*/
public class SwingUtilities2 {
/**
* The <code>AppContext</code> key for our one <code>LAFState</code>
* instance.
*/
new StringBuffer("LookAndFeel State");
// Maintain a cache of CACHE_SIZE fonts and the left side bearing
// of the characters falling into the range MIN_CHAR_INDEX to
// MAX_CHAR_INDEX. The values in fontCache are created as needed.
// Windows defines 6 font desktop properties, we will therefore only
// cache the metrics for 6 fonts.
// nextIndex in fontCache to insert a font into.
private static int nextIndex;
// LSBCacheEntry used to search in fontCache to see if we already
// have an entry for a particular font
// getLeftSideBearing will consult all characters that fall in the
// range MIN_CHAR_INDEX to MAX_CHAR_INDEX.
new FontRenderContext(null, false, false);
/**
* A JComponent client property is used to determine text aa settings.
* To avoid having this property persist between look and feels changes
* the value of the property is set to null in JComponent.setUI
*/
new StringBuffer("AATextInfoPropertyKey");
/**
* Attribute key for the content elements. If it is set on an element, the
* element is considered to be a line break.
*/
/**
* Used to tell a text component, being used as an editor for table
* or tree, how many clicks it took to start editing.
*/
new StringBuilder("skipClickCount");
/* Presently this class assumes default fractional metrics.
* This may need to change to emulate future platform L&Fs.
*/
public static class AATextInfo {
return null;
} else {
}
}
} else {
return null;
}
}
/* These are rarely constructed objects, and only when a complete
* UI is being updated, so the cost of the tests here is minimal
* and saves tests elsewhere.
*/
throw new InternalError("null not allowed here");
}
if (aaHint == VALUE_TEXT_ANTIALIAS_OFF ||
throw new InternalError("AA must be on");
}
this.lcdContrastHint = lcdContrastHint;
}
}
/**
* Key used in client properties used to indicate that the
* <code>ComponentUI</code> of the JComponent instance should be returned.
*/
new StringBuffer("ComponentUIPropertyKey");
/** Client Property key for the text maximal offsets for BasicMenuItemUI */
new StringUIClientPropertyKey ("maxTextOffset");
// security stuff
"UNTRUSTED_CLIPBOARD_ACCESS_KEY";
//all access to charsBuffer is to be synchronized on charsBufferLock
static {
}
/**
* Fill the character buffer cache. Return the buffer length.
*/
charsBuffer = s.toCharArray();
} else {
}
return length;
}
/**
* checks whether TextLayout is required to handle characters.
*
* @param text characters to be tested
* @param start start
* @param limit limit
* @return <tt>true</tt> if TextLayout is required
* <tt>false</tt> if TextLayout is not required
*/
}
//
// WARNING WARNING WARNING WARNING WARNING WARNING
// Many of the following methods are invoked from older API.
// As this older API was not passed a Component, a null Component may
// now be passsed in. For example, SwingUtilities.computeStringWidth
// is implemented to call SwingUtilities2.stringWidth, the
// SwingUtilities variant does not take a JComponent, as such
// SwingUtilities2.stringWidth can be passed a null Component.
// In other words, if you add new functionality to these methods you
// need to gracefully handle null.
//
/**
* Returns whether or not text should be drawn antialiased.
*
* @param c JComponent to test.
* @return Whether or not text should be drawn antialiased for the
* specified component.
*/
if (c != null) {
/* a non-null property implies some form of AA requested */
}
// No component, assume aa is off
return null;
}
/**
* Returns the left side bearing of the first character of string. The
* left side bearing is calculated from the passed in
* FontMetrics. If the passed in String is less than one
* character {@code 0} is returned.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param string String to get the left side bearing for.
* @throws NullPointerException if {@code string} is {@code null}
*
* @return the left side bearing of the first character of string
* or {@code 0} if the string is empty
*/
return 0;
}
}
/**
* Returns the left side bearing of the first character of string. The
* left side bearing is calculated from the passed in FontMetrics.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param firstChar Character to get the left side bearing for.
*/
char firstChar) {
synchronized (SwingUtilities2.class) {
} else {
}
// See if we already have an entry for this pair
entry = cacheEntry;
break;
}
}
// No entry for this pair, add it.
}
}
}
return 0;
}
/**
* Returns the FontMetrics for the current Font of the passed
* in Graphics. This method is used when a Graphics
* is available, typically when painting. If a Graphics is not
* available the JComponent method of the same name should be used.
* <p>
* Callers should pass in a non-null JComponent, the exception
* to this is if a JComponent is not readily available at the time of
* painting.
* <p>
* This does not necessarily return the FontMetrics from the
* Graphics.
*
* @param c JComponent requesting FontMetrics, may be null
* @param g Graphics Graphics
*/
return getFontMetrics(c, g, g.getFont());
}
/**
* Returns the FontMetrics for the specified Font.
* This method is used when a Graphics is available, typically when
* painting. If a Graphics is not available the JComponent method of
* the same name should be used.
* <p>
* Callers should pass in a non-null JComonent, the exception
* to this is if a JComponent is not readily available at the time of
* painting.
* <p>
* This does not necessarily return the FontMetrics from the
* Graphics.
*
* @param c JComponent requesting FontMetrics, may be null
* @param c Graphics Graphics
* @param font Font to get FontMetrics for
*/
if (c != null) {
// Note: We assume that we're using the FontMetrics
// from the widget to layout out text, otherwise we can get
// mismatches when printing.
return c.getFontMetrics(font);
}
}
/**
* Returns the width of the passed in String.
* If the passed String is <code>null</code>, returns zero.
*
* @param c JComponent that will display the string, may be null
* @param fm FontMetrics used to measure the String width
* @param string String to get the width of
*/
return 0;
}
boolean needsTextLayout = ((c != null) &&
if (needsTextLayout) {
synchronized(charsBufferLock) {
}
}
if (needsTextLayout) {
return (int) layout.getAdvance();
} else {
}
}
/**
* Clips the passed in String to the space provided.
*
* @param c JComponent that will display the string, may be null
* @param fm FontMetrics used to measure the String width
* @param string String to display
* @param availTextWidth Amount of space that the string can be drawn in
* @return Clipped string that can fit in the provided space.
*/
int availTextWidth) {
return "";
}
if (textWidth > availTextWidth) {
}
return string;
}
/**
* Clips the passed in String to the space provided. NOTE: this assumes
* the string does not fit in the available space.
*
* @param c JComponent that will display the string, may be null
* @param fm FontMetrics used to measure the String width
* @param string String to display
* @param availTextWidth Amount of space that the string can be drawn in
* @return Clipped string that can fit in the provided space.
*/
// c may be null here.
if (availTextWidth <= 0) {
//can not fit any characters
return clipString;
}
boolean needsTextLayout;
synchronized (charsBufferLock) {
if (!needsTextLayout) {
int width = 0;
if (width > availTextWidth) {
break;
}
}
}
}
if (needsTextLayout) {
if (c != null) {
}
}
return string + clipString;
}
/**
* Draws the string at the specified location.
*
* @param c JComponent that will display the string, may be null
* @param g Graphics to draw the text to
* @param text String to display
* @param x X coordinate to draw the text at
* @param y Y coordinate to draw the text at
*/
int x, int y) {
// c may be null
// All non-editable widgets that draw strings call into this
// methods. By non-editable that means widgets like JLabel, JButton
// but NOT JTextComponents.
return;
}
if (isPrinting(g)) {
/* The printed text must scale linearly with the UI.
* Calculate the width on screen, obtain a TextLayout with
* advances for the printer graphics FRC, and then justify
* it to fit in the screen width. This distributes the spacing
* more evenly than directly laying out to the screen advances.
*/
float screenWidth = (float)
/* Use alternate print color if specified */
if (col instanceof PrintColorUIResource) {
}
return;
}
}
// If we get here we're not printing
} else {
oldAAValue = null;
}
oldContrast = null;
} else {
}
}
boolean needsTextLayout = ((c != null) &&
if (needsTextLayout) {
synchronized(charsBufferLock) {
}
}
if (needsTextLayout) {
} else {
g.drawString(text, x, y);
}
if (oldAAValue != null) {
}
if (oldContrast != null) {
}
}
else {
g.drawString(text, x, y);
}
}
/**
* Draws the string at the specified location underlining the specified
* character.
*
* @param c JComponent that will display the string, may be null
* @param g Graphics to draw the text to
* @param text String to display
* @param underlinedIndex Index of a character in the string to underline
* @param x X coordinate to draw the text at
* @param y Y coordinate to draw the text at
*/
return;
}
int underlineRectY = y;
int underlineRectHeight = 1;
int underlineRectX = 0;
int underlineRectWidth = 0;
boolean isPrinting = isPrinting(g);
boolean needsTextLayout = isPrinting;
if (!needsTextLayout) {
synchronized (charsBufferLock) {
}
}
if (!needsTextLayout) {
underlineRectX = x +
} else {
if (isPrinting) {
}
underlineRectX = x + rect.x;
}
}
}
}
/**
* A variation of locationToIndex() which only returns an index if the
* Point is within the actual bounds of a list item (not just in the cell)
* and if the JList has the "List.isFileList" client property set.
* Otherwise, this method returns -1.
* This is used to make WindowsL&F JFileChooser act like native dialogs.
*/
if (index != -1) {
index = -1;
}
}
return index;
}
/**
* Returns true if the given point is within the actual bounds of the
* JList item at index (not just inside the cell).
*/
}
}
/**
* Returns true if the given point is outside the preferredSize of the
* item at the given row of the table. (Column must be 0).
* Does not check the "Table.isFileList" property. That should be checked
* before calling this method.
* This is used to make WindowsL&F JFileChooser act like native dialogs.
*/
return true;
}
// See if coords are inside
// ASSUME: mouse x,y will never be < cell's x,y
assert (p.x >= cellBounds.x && p.y >= cellBounds.y);
}
/**
* Set the lead and anchor without affecting selection.
*/
if (anchor == -1) {
}
if (lead == -1) {
} else {
} else {
}
}
}
/**
* Ignore mouse events if the component is null, not enabled, the event
* is not associated with the left mouse button, or the event has been
* consumed.
*/
|| me.isConsumed();
}
/**
* Request focus on the given component if it doesn't already have it
* and <code>isRequestFocusEnabled()</code> returns true.
*/
if (!c.hasFocus() && c.isRequestFocusEnabled()) {
c.requestFocus();
}
}
/**
* The following draw functions have the same semantic as the
* Graphics methods with the same names.
*
* this is used for printing
*/
char[] data,
int offset,
int length,
int x,
int y) {
return x;
}
if (isPrinting(g)) {
(deviceFontRenderContext, frc)) {
getWidth();
/* Use alternate print color if specified */
if (col instanceof PrintColorUIResource) {
}
return nextX;
}
}
}
// Assume we're not printing if we get here, or that we are invoked
// via Swing text printing which is laid out for the printer.
} else {
oldAAValue = null;
}
oldContrast = null;
} else {
}
}
if (oldAAValue != null) {
}
if (oldContrast != null) {
}
}
else {
}
return nextX;
}
/*
* see documentation for drawChars
* returns the advance
*/
int x,
int y) {
float retVal;
boolean isPrinting = isPrinting(g);
if (isPrinting) {
/* Use alternate print color if specified */
if (col instanceof PrintColorUIResource) {
}
}
//matters it should not happen
retVal = x;
} else {
if (isPrinting) {
frc = getFontRenderContext(c);
}
/* frc = frc; ! */
} else {
}
if (isPrinting) {
}
}
}
if (isPrinting) {
}
return retVal;
}
return new TextLayout(s, f, frc);
} else {
return new TextLayout(s, a, frc);
}
}
/*
* Checks if two given FontRenderContexts are compatible for printing.
* We can't just use equals as we want to exclude from the comparison :
* + whether AA is set as irrelevant for printing and shouldn't affect
* printed metrics anyway
* + any translation component in the transform of either FRC, as it
* does not affect metrics.
* Compatible means no special handling needed for text painting
*/
private static boolean
return true;
}
return false;
}
if (frc1.getFractionalMetricsHint() !=
return false;
}
/* If both are identity, return true */
return true;
}
/* That's the end of the cheap tests, need to get and compare
* the transform matrices. We don't care about the translation
* components, so return true if they are otherwise identical.
*/
double[] mat1 = new double[4];
double[] mat2 = new double[4];
return
}
/*
* Tries it best to get Graphics2D out of the given Graphics
* returns null if can not derive it.
*/
if (g instanceof Graphics2D) {
return (Graphics2D) g;
} else if (g instanceof ProxyPrintGraphics) {
} else {
return null;
}
}
/*
* Returns FontRenderContext associated with Component.
* FontRenderContext from Component.getFontMetrics is associated
* with the component.
*
* Uses Component.getFontMetrics to get the FontRenderContext from.
* see JComponent.getFontMetrics and TextLayoutStrategy.java
*/
assert c != null;
if (c == null) {
return DEFAULT_FRC;
} else {
}
}
/**
* A convenience method to get FontRenderContext.
* Returns the FontRenderContext for the passed in FontMetrics or
* for the passed in Component if FontMetrics is null
*/
: getFontRenderContext(c);
}
/*
* This method is to be used only for JComponent.getFontMetrics.
* In all other places to get FontMetrics we need to use
* JComponent.getFontMetrics.
*
*/
frc = DEFAULT_FRC;
}
}
/* Get any FontRenderContext associated with a JComponent
* - may return null
*/
if (c != null) {
}
}
return null;
}
/*
* returns true if the Graphics is print Graphics
* false otherwise
*/
return (g instanceof PrinterGraphics || g instanceof PrintGraphics);
}
/**
* Determines whether the SelectedTextColor should be used for painting text
* foreground for the specified highlight.
*
* Returns true only if the highlight painter for the specified highlight
* is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
* or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
* is null or equals to the selection color of the text component.
*
* This is a hack for fixing both bugs 4761990 and 5003294
*/
return false;
}
try {
return false;
}
} catch (ClassCastException e) {
return false;
}
return true;
}
/**
* LSBCacheEntry is used to cache the left side bearing (lsb) for
* a particular <code>Font</code> and <code>FontRenderContext</code>.
* This only caches characters that fall in the range
* <code>MIN_CHAR_INDEX</code> to <code>MAX_CHAR_INDEX</code>.
*/
private static class LSBCacheEntry {
// Used to indicate a particular entry in lsb has not been set.
// Used in creating a GlyphVector to get the lsb
private byte[] lsbCache;
}
}
}
if (lsb < 0) {
* on the left used in colour fringe reduction.
* Text rendering positions this correctly but here
* we are using the glyph image to adjust that position
* so must account for it.
*/
if (aaHint == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
lsb++;
}
}
}
return lsb;
}
if (entry == this) {
return true;
}
if (!(entry instanceof LSBCacheEntry)) {
return false;
}
}
public int hashCode() {
int result = 17;
}
}
return result;
}
}
/*
* here goes the fix for 4856343 [Problem with applet interaction
* with system selection clipboard]
*
* NOTE. In case isTrustedContext() no checking
* are to be performed
*/
/**
* checks the security permissions for accessing system clipboard
*
* for untrusted context (see isTrustedContext) checks the
* permissions for the current event being handled
*
*/
public static boolean canAccessSystemClipboard() {
boolean canAccess = false;
if (!GraphicsEnvironment.isHeadless()) {
canAccess = true;
} else {
try {
canAccess = true;
} catch (SecurityException e) {
}
if (canAccess && ! isTrustedContext()) {
}
}
}
return canAccess;
}
/**
* Returns true if EventQueue.getCurrentEvent() has the permissions to
* access the system clipboard
*/
public static boolean canCurrentEventAccessSystemClipboard() {
return isTrustedContext()
|| canCurrentEventAccessSystemClipboard(false);
}
/**
* Returns true if the given event has permissions to access the
* system clipboard
*
* @param e AWTEvent to check
*/
return isTrustedContext()
|| canEventAccessSystemClipboard(e, false);
}
/**
* returns canAccessSystemClipboard field from InputEvent
*
* @param ie InputEvent to get the field from
*/
try {
getDeclaredField("canAccessSystemClipboard");
field.setAccessible(true);
return field;
} catch (SecurityException e) {
} catch (NoSuchFieldException e) {
}
return null;
}
});
}
return false;
}
boolean ret = false;
try {
getBoolean(ie);
} catch(IllegalAccessException e) {
}
return ret;
}
/**
* Returns true if the given event is corrent gesture for
* accessing clipboard
*
* @param ie InputEvent to check
*/
boolean allowedGesture = false;
switch(keyCode) {
break;
break;
allowedGesture = true;
break;
break;
}
}
return allowedGesture;
}
/**
* Returns true if e has the permissions to
* access the system clipboard and if it is allowed gesture (if
* checkGesture is true)
*
* @param e AWTEvent to check
* @param checkGesture boolean
*/
boolean checkGesture) {
if (EventQueue.isDispatchThread()) {
/*
* Checking event permissions makes sense only for event
* dispathing thread
*/
if (e instanceof InputEvent
return inputEvent_canAccessSystemClipboard((InputEvent)e);
} else {
return false;
}
} else {
return true;
}
}
/**
* Returns true if EventQueue.getCurrentEvent() has the permissions to
* access the system clipboard and if it is allowed gesture (if
* checkGesture true)
*
* @param checkGesture boolean
*/
private static boolean canCurrentEventAccessSystemClipboard(boolean
checkGesture) {
}
/**
* see RFE 5012841 [Per AppContect security permissions] for the
* details
*
*/
private static boolean isTrustedContext() {
|| (AppContext.getAppContext().
}
}
}
}
}
}
}
}
}
/**
* Utility method that creates a <code>UIDefaults.LazyValue</code> that
* creates an <code>ImageIcon</code> <code>UIResource</code> for the
* specified image file name. The image is loaded using
* <code>getResourceAsStream</code>, starting with a call to that method
* on the base class parameter. If it cannot be found, searching will
* continue through the base class' inheritance hierarchy, up to and
* including <code>rootClass</code>.
*
* @param baseClass the first class to use in searching for the resource
* @param rootClass an ancestor of <code>baseClass</code> to finish the
* search at
* @param imageFile the name of the file to be found
* @return a lazy value that creates the <code>ImageIcon</code>
* <code>UIResource</code> for the image,
* or null if it cannot be found
*/
return new UIDefaults.LazyValue() {
/* Copy resource into a byte array. This is
* necessary because several browsers consider
* Class.getResource a security risk because it
* can be used to load additional classes.
* Class.getResourceAsStream just returns raw
* bytes, which we can convert to an image.
*/
byte[] buffer =
public byte[] run() {
try {
break;
}
}
return null;
}
new BufferedInputStream(resource);
new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
int n;
}
return out.toByteArray();
} catch (IOException ioe) {
}
return null;
}
});
return null;
}
" is zero-length");
return null;
}
return new ImageIconUIResource(buffer);
}
};
}
/* Used to help decide if AA text rendering should be used, so
* this local display test should be additionally qualified
* against whether we have XRender support on both ends of the wire,
* as with that support remote performance may be good enough to turn
* on by default. An additional complication there is XRender does not
* appear capable of performing gamma correction needed for LCD text.
*/
public static boolean isLocalDisplay() {
boolean isLocal;
if (ge instanceof SunGraphicsEnvironment) {
} else {
isLocal = true;
}
return isLocal;
}
/**
* Returns an integer from the defaults table. If <code>key</code> does
* not map to a valid <code>Integer</code>, or can not be convered from
* a <code>String</code> to an integer, the value 0 is returned.
*
* @param key an <code>Object</code> specifying the int.
* @return the int
*/
}
/**
* Returns an integer from the defaults table that is appropriate
* for the given locale. If <code>key</code> does not map to a valid
* <code>Integer</code>, or can not be convered from a <code>String</code>
* to an integer, the value 0 is returned.
*
* @param key an <code>Object</code> specifying the int. Returned value
* is 0 if <code>key</code> is not available,
* @param l the <code>Locale</code> for which the int is desired
* @return the int
*/
}
/**
* Returns an integer from the defaults table. If <code>key</code> does
* not map to a valid <code>Integer</code>, or can not be convered from
* a <code>String</code> to an integer, <code>default</code> is
* returned.
*
* @param key an <code>Object</code> specifying the int. Returned value
* is 0 if <code>key</code> is not available,
* @param defaultValue Returned value if <code>key</code> is not available,
* or is not an Integer
* @return the int
*/
}
/**
* Returns an integer from the defaults table that is appropriate
* for the given locale. If <code>key</code> does not map to a valid
* <code>Integer</code>, or can not be convered from a <code>String</code>
* to an integer, <code>default</code> is returned.
*
* @param key an <code>Object</code> specifying the int. Returned value
* is 0 if <code>key</code> is not available,
* @param l the <code>Locale</code> for which the int is desired
* @param defaultValue Returned value if <code>key</code> is not available,
* or is not an Integer
* @return the int
*/
}
try {
} catch (NumberFormatException nfe) {}
}
return defaultValue;
}
// At this point we need this method here. But we assume that there
// will be a common method for this purpose in the future releases.
if (container.isFocusCycleRoot()) {
comp.requestFocus();
return comp;
}
}
if (rootAncestor!=null) {
comp.requestFocus();
return comp;
}
}
}
if (component.isFocusable()) {
return component;
}
return null;
}
/**
* Change focus to the visible component in {@code JTabbedPane}.
* This is not a general-purpose method and is here only to permit
* sharing code.
*/
if (comp.isFocusTraversable()) {
return true;
} else if (comp instanceof JComponent
return true;
}
}
return false;
}
/**
* Submits a value-returning task for execution on the EDT and
* returns a Future representing the pending results of the task.
*
* @param task the task to submit
* @return a Future representing pending completion of the task
* @throws NullPointerException if the task is null
*/
throw new NullPointerException();
}
return future;
}
/**
* Submits a Runnable task for execution on the EDT and returns a
* Future representing that task.
*
* @param task the task to submit
* @param result the result to return upon successful completion
* @return a Future representing pending completion of the task,
* and whose <tt>get()</tt> method will return the given
* result value upon completion
* @throws NullPointerException if the task is null
*/
throw new NullPointerException();
}
return future;
}
/**
* Sends a Runnable to the EDT for the execution.
*/
}
/**
* Sets the {@code SKIP_CLICK_COUNT} client property on the component
* if it is an instance of {@code JTextComponent} with a
* {@code DefaultCaret}. This property, used for text components acting
* as editors in a table or tree, tells {@code DefaultCaret} how many
* clicks to skip before starting selection.
*/
if (comp instanceof JTextComponent
}
}
/**
* Return the MouseEvent's click count, possibly reduced by the value of
* the component's {@code SKIP_CLICK_COUNT} client property. Clears
* the {@code SKIP_CLICK_COUNT} property if the mouse event's click count
* is 1. In order for clearing of the property to work correctly, there
* must be a mousePressed implementation on the caller with this
* call as the first line.
*/
int cc = e.getClickCount();
if (cc == 1) {
} else {
}
}
return cc;
}
/**
* Used by the {@code liesIn} method to return which section
* the point lies in.
*
* @see #liesIn
*/
public enum Section {
/** The leading section */
/** The middle section */
/** The trailing section */
}
/**
* This method divides a rectangle into two or three sections along
* the specified axis and determines which section the given point
* lies in on that axis; used by drag and drop when calculating drop
* locations.
* <p>
* For two sections, the rectangle is divided equally and the method
* returns whether the point lies in {@code Section.LEADING} or
* {@code Section.TRAILING}. For horizontal divisions, the calculation
* respects component orientation.
* <p>
* For three sections, if the rectangle is greater than or equal to
* 30 pixels in length along the axis, the calculation gives 10 pixels
* to each of the leading and trailing sections and the remainder to the
* middle. For smaller sizes, the rectangle is divided equally into three
* sections.
* <p>
* Note: This method assumes that the point is within the bounds of
* the given rectangle on the specified axis. However, in cases where
* it isn't, the results still have meaning: {@code Section.MIDDLE}
* remains the same, {@code Section.LEADING} indicates that the point
* is in or somewhere before the leading section, and
* {@code Section.TRAILING} indicates that the point is in or somewhere
* after the trailing section.
*
* @param rect the rectangle
* @param p the point the check
* @param horizontal {@code true} to use the horizontal axis,
* or {@code false} for the vertical axis
* @param ltr {@code true} for left to right orientation,
* or {@code false} for right to left orientation;
* only used for horizontal calculations
* @param three {@code true} for three sections,
* or {@code false} for two
*
* @return the {@code Section} where the point lies
*
* @throws NullPointerException if {@code rect} or {@code p} are
* {@code null}
*/
/* beginning of the rectangle on the axis */
int p0;
/* point on the axis we're interested in */
int pComp;
/* length of the rectangle on the axis */
int length;
/* value of ltr if horizontal, else true */
boolean forward;
if (horizontal) {
pComp = p.x;
} else {
pComp = p.y;
forward = true;
}
if (three) {
}
} else {
if (forward) {
} else {
}
}
}
/**
* This method divides a rectangle into two or three sections along
* the horizontal axis and determines which section the given point
* lies in; used by drag and drop when calculating drop locations.
* <p>
* See the documentation for {@link #liesIn} for more information
* on how the section is calculated.
*
* @param rect the rectangle
* @param p the point the check
* @param ltr {@code true} for left to right orientation,
* or {@code false} for right to left orientation
* @param three {@code true} for three sections,
* or {@code false} for two
*
* @return the {@code Section} where the point lies
*
* @throws NullPointerException if {@code rect} or {@code p} are
* {@code null}
*/
}
/**
* This method divides a rectangle into two or three sections along
* the vertical axis and determines which section the given point
* lies in; used by drag and drop when calculating drop locations.
* <p>
* See the documentation for {@link #liesIn} for more information
* on how the section is calculated.
*
* @param rect the rectangle
* @param p the point the check
* @param three {@code true} for three sections,
* or {@code false} for two
*
* @return the {@code Section} where the point lies
*
* @throws NullPointerException if {@code rect} or {@code p} are
* {@code null}
*/
boolean three) {
}
/**
* Maps the index of the column in the view at
* {@code viewColumnIndex} to the index of the column
* in the table model. Returns the index of the corresponding
* column in the model. If {@code viewColumnIndex}
* is less than zero, returns {@code viewColumnIndex}.
*
* @param cm the table model
* @param viewColumnIndex the index of the column in the view
* @return the index of the corresponding column in the model
*
* @see JTable#convertColumnIndexToModel(int)
* @see javax.swing.plaf.basic.BasicTableHeaderUI
*/
int viewColumnIndex) {
if (viewColumnIndex < 0) {
return viewColumnIndex;
}
}
/**
* Maps the index of the column in the {@code cm} at
* {@code modelColumnIndex} to the index of the column
* in the view. Returns the index of the
* corresponding column in the view; returns {@code -1} if this column
* is not being displayed. If {@code modelColumnIndex} is less than zero,
* returns {@code modelColumnIndex}.
*
* @param cm the table model
* @param modelColumnIndex the index of the column in the model
* @return the index of the corresponding column in the view
*
* @see JTable#convertColumnIndexToView(int)
* @see javax.swing.plaf.basic.BasicTableHeaderUI
*/
int modelColumnIndex) {
if (modelColumnIndex < 0) {
return modelColumnIndex;
}
return column;
}
}
return -1;
}
public static int getSystemMnemonicKeyMask() {
if (toolkit instanceof SunToolkit) {
}
return InputEvent.ALT_MASK;
}
}