< prev index next >
src/java.desktop/share/classes/java/awt/FontMetrics.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 330,340 ****
*/
public int charWidth(char ch) {
if (ch < 256) {
return getWidths()[ch];
}
! char data[] = {ch};
return charsWidth(data, 0, 1);
}
/**
* Returns the total advance width for showing the specified
--- 330,340 ----
*/
public int charWidth(char ch) {
if (ch < 256) {
return getWidths()[ch];
}
! char[] data = {ch};
return charsWidth(data, 0, 1);
}
/**
* Returns the total advance width for showing the specified
*** 353,363 ****
* @see #charsWidth(char[], int, int)
* @see #getStringBounds(String, Graphics)
*/
public int stringWidth(String str) {
int len = str.length();
! char data[] = new char[len];
str.getChars(0, len, data, 0);
return charsWidth(data, 0, len);
}
/**
--- 353,363 ----
* @see #charsWidth(char[], int, int)
* @see #getStringBounds(String, Graphics)
*/
public int stringWidth(String str) {
int len = str.length();
! char[] data = new char[len];
str.getChars(0, len, data, 0);
return charsWidth(data, 0, len);
}
/**
*** 381,391 ****
* @see #charWidth(int)
* @see #charWidth(char)
* @see #bytesWidth(byte[], int, int)
* @see #stringWidth(String)
*/
! public int charsWidth(char data[], int off, int len) {
return stringWidth(new String(data, off, len));
}
/**
* Returns the total advance width for showing the specified array
--- 381,391 ----
* @see #charWidth(int)
* @see #charWidth(char)
* @see #bytesWidth(byte[], int, int)
* @see #stringWidth(String)
*/
! public int charsWidth(char[] data, int off, int len) {
return stringWidth(new String(data, off, len));
}
/**
* Returns the total advance width for showing the specified array
*** 408,418 ****
* the bounds of the {@code data} array.
* @see #charsWidth(char[], int, int)
* @see #stringWidth(String)
*/
@SuppressWarnings("deprecation")
! public int bytesWidth(byte data[], int off, int len) {
return stringWidth(new String(data, 0, off, len));
}
/**
* Gets the advance widths of the first 256 characters in the
--- 408,418 ----
* the bounds of the {@code data} array.
* @see #charsWidth(char[], int, int)
* @see #stringWidth(String)
*/
@SuppressWarnings("deprecation")
! public int bytesWidth(byte[] data, int off, int len) {
return stringWidth(new String(data, 0, off, len));
}
/**
* Gets the advance widths of the first 256 characters in the
*** 424,434 ****
* @return an array storing the advance widths of the
* characters in the {@code Font}
* described by this {@code FontMetrics} object.
*/
public int[] getWidths() {
! int widths[] = new int[256];
for (char ch = 0 ; ch < 256 ; ch++) {
widths[ch] = charWidth(ch);
}
return widths;
}
--- 424,434 ----
* @return an array storing the advance widths of the
* characters in the {@code Font}
* described by this {@code FontMetrics} object.
*/
public int[] getWidths() {
! int[] widths = new int[256];
for (char ch = 0 ; ch < 256 ; ch++) {
widths[ch] = charWidth(ch);
}
return widths;
}
< prev index next >