|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiggests.utils.VerticalTextIcon
public class VerticalTextIcon
Title: Vertical Text Icon
Description: VerticalTextIcon is an Icon implementation which draws a short string vertically. It's useful for JTabbedPanes with LEFT or RIGHT tabs but can be used in any component which supports Icons, such as JLabel or JButton. You can provide a hint to indicate whether to rotate the string to the left or right, or not at all, and it checks to make sure that the rotation is legal for the given string (for example, Chinese/Japanese/Korean scripts have special rules when drawn vertically and should never be rotated).
Copyright: Copyright (C) 2007 Joana P. Gonçalves This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. 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.
Field Summary | |
---|---|
static int |
DEFAULT_CJK
Default CJK's rotation. |
static int |
DEFAULT_MUST_ROTATE
Default must rotate rotation. |
static int |
DEFAULT_ROMAN
Default roman rotation. |
protected int |
fCharHeight
The width and height of the label, character height and descent. |
protected java.lang.String[] |
fCharStrings
The label parsed into one-char strings. |
protected int[] |
fCharWidths
The characters widths. |
protected java.awt.Component |
fComponent
The component in which the label will be drawn. |
protected int |
fDescent
The width and height of the label, character height and descent. |
protected int |
fHeight
The width and height of the label, character height and descent. |
protected java.lang.String |
fLabel
The label to rotate. |
protected int[] |
fPosition
The position of the characters. |
protected int |
fRotation
The rotation of the label. |
protected int |
fWidth
The width and height of the label, character height and descent. |
static int |
kBufferSpace
Buffer size. |
static int |
LEGAL_MUST_ROTATE
Valid must rotate rotations. |
static int |
LEGAL_ROMAN
Valid roman's rotations. |
static double |
NINETY_DEGREES
Ninety degrees rotation. |
static int |
POSITION_FAR_TOP_RIGHT
The far top right position. |
static int |
POSITION_NORMAL
The normal position. |
static int |
POSITION_TOP_RIGHT
The top right position. |
static int |
ROTATE_DEFAULT
The default rotation. |
static int |
ROTATE_LEFT
The left rotation option. |
static int |
ROTATE_NONE
The no rotation option. |
static int |
ROTATE_RIGHT
The right rotation option. |
Constructor Summary | |
---|---|
VerticalTextIcon(java.awt.Component component,
java.lang.String label)
Creates a VerticalTextIcon for the specified
component with the specified label . |
|
VerticalTextIcon(java.awt.Component component,
java.lang.String label,
int rotateHint)
Creates a VerticalTextIcon for the specified
component with the specified label . |
Method Summary | |
---|---|
int |
getIconHeight()
Returns the icon's height. |
int |
getIconWidth()
Returns the icon's width. |
void |
paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
Draws the icon at the specified location. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
Checks for changes to the font on the fComponent
so that it can invalidate the layout if the size changes. |
void |
setLabel(java.lang.String label)
Sets the fLabel to the given label string,
updating the orientation as needed and invalidating the layout if
the size changes. |
static int |
verifyRotation(java.lang.String label,
int rotateHint)
Returns the best rotation for the string: - ROTATE_NONE - ROTATE_LEFT - ROTATE_RIGHT This is public static so you can use it to test a string without creating a VerticalTextIcon. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String fLabel
protected java.lang.String[] fCharStrings
protected int[] fCharWidths
protected int[] fPosition
protected int fWidth
protected int fHeight
protected int fCharHeight
protected int fDescent
protected int fRotation
protected java.awt.Component fComponent
public static final int POSITION_NORMAL
public static final int POSITION_TOP_RIGHT
public static final int POSITION_FAR_TOP_RIGHT
public static final int ROTATE_DEFAULT
public static final int ROTATE_NONE
public static final int ROTATE_LEFT
public static final int ROTATE_RIGHT
public static final int DEFAULT_CJK
public static final int LEGAL_ROMAN
public static final int DEFAULT_ROMAN
public static final int LEGAL_MUST_ROTATE
public static final int DEFAULT_MUST_ROTATE
public static final double NINETY_DEGREES
public static final int kBufferSpace
Constructor Detail |
---|
public VerticalTextIcon(java.awt.Component component, java.lang.String label)
VerticalTextIcon
for the specified
component
with the specified label
.
It sets the orientation to the default for the string.
component
- the Component
to create the label forlabel
- the String label
for the given
component
verifyRotation(java.lang.String, int)
public VerticalTextIcon(java.awt.Component component, java.lang.String label, int rotateHint)
VerticalTextIcon
for the specified
component
with the specified label
.
It sets the orientation to the provided value if it's legal
for the string.
component
- the Component
to create the label forlabel
- the String label
for the given
component
rotateHint
- int the value for text rotationverifyRotation(java.lang.String, int)
Method Detail |
---|
public void setLabel(java.lang.String label)
fLabel
to the given label
string,
updating the orientation as needed and invalidating the layout if
the size changes.
label
- StringverifyRotation(java.lang.String, int)
public void propertyChange(java.beans.PropertyChangeEvent e)
fComponent
so that it can invalidate the layout if the size changes.
propertyChange
in interface java.beans.PropertyChangeListener
e
- the PropertyChangeEvent
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
paintIcon
in interface javax.swing.Icon
c
- the Component
to drawg
- the Graphics
where to draw the component
x
- int the x-coordinate of the component
's locationy
- int the y-coordinate of the component
's locationpublic int getIconWidth()
getIconWidth
in interface javax.swing.Icon
public int getIconHeight()
getIconHeight
in interface javax.swing.Icon
public static int verifyRotation(java.lang.String label, int rotateHint)
ROTATE_NONE
ROTATE_LEFT
ROTATE_RIGHT
from http://www.unicode.org/unicode/reports/tr9/tr9-3.html:
When setting text using the Arabic script in vertical lines,
it is more common to employ a horizontal baseline that
is rotated by 90� counterclockwise so that the characters
are ordered from top to bottom. Latin text and numbers
may be rotated 90� clockwise so that the characters
are also ordered from top to bottom.
Rotation rules
- Roman can rotate left, right, or none - default right (counterclockwise)
- CJK can't rotate
- Arabic must rotate - default left (clockwise)
from the online edition of _The Unicode Standard, Version 3.0_, file ch10.pdf page 4:
Ideographs are found in three blocks of the Unicode Standard:
U+4E00-U+9FFF
U+3400-U+4DFF
U+F900-U+FAFF
from http://www.unicode.org/unicode/faq/writingdirections.html:
East Asian scripts are frequently written in vertical lines
which run from top-to-bottom and are arrange columns either
from left-to-right (Mongolian) or right-to-left (other scripts).
Most characters use the same shape and orientation when displayed
horizontally or vertically, but many punctuation characters
will change their shape when displayed vertically.
Letters and words from other scripts are generally rotated through ninety degree angles so that they, too, will read from top to bottom. That is, letters from left-to-right scripts will be rotated clockwise and letters from right-to-left scripts counterclockwise, both through ninety degree angles.
Unlike the bidirectional case, the choice of vertical layout is usually treated as a formatting style; therefore, the Unicode Standard does not define default rendering behavior for vertical text nor provide directionality controls designed to override such behavior
label
- String the string that we want to apply the rotation torotateHint
- int the kind of rotation that we want to apply to the string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |