Package com.zerog.awt
Class ZGSimpleTextWrap
- java.lang.Object
-
- java.awt.Component
-
- com.zerog.awt.ZGSimpleTextWrap
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable
public class ZGSimpleTextWrap extends java.awt.ComponentZGSimpleTextWrap: Lightweight TextDisplay that automatically wraps text. Think of it as a kind of WrappingTextLabel.- Version:
- 0.8, 12 Jul 2000
- Author:
- M. Michael Acosta
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intbufstatic intCENTERprotected intdoubleBufstatic intLEFTprotected booleannewFontstatic intRIGHTprotected java.lang.Stringtextprotected java.awt.ColortextColorprotected java.util.VectortextVprotected intvSpace
-
Constructor Summary
Constructors Constructor Description ZGSimpleTextWrap()Creates a new TextDisplay Component, with the given text.ZGSimpleTextWrap(java.lang.String text)Creates a new TextDisplay Component, with the given text.ZGSimpleTextWrap(java.lang.String text, int hAlignment)Creates a new TextDisplay Component, with the given text.ZGSimpleTextWrap(java.lang.String text, int hAlignment, java.awt.Color controlTextColor)ZGSimpleTextWrap(java.lang.String text, java.awt.Color textColor)Creates a new TextDisplay Component, with the given text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAlignment()Gets the current hAlignment.java.lang.StringgetComponentID()java.awt.DimensiongetMaximumSize()java.awt.DimensiongetMinimumSize()java.awt.DimensiongetPreferredSize()java.awt.DimensiongetSize()intgetStringWidth(java.lang.String str, java.awt.FontMetrics fm)java.lang.StringgetText()voidpaint(java.awt.Graphics g1)Paints this component.intparseText()Parses the text into a vector of individual lines of text based on the current width of the component.voidsetAlignment(int hAlignment)Sets the current hAlignment.voidsetBounds(int x, int y, int width, int height)voidsetComponentID(java.lang.String component_id)voidsetSize(int width, int height)voidsetWidth(int width)Sets the width (around which text will be wrapped) for this component.voidupdate(java.awt.Graphics g)Updates the component.-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
-
-
-
Field Detail
-
LEFT
public static final int LEFT
- See Also:
- Constant Field Values
-
CENTER
public static final int CENTER
- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
- See Also:
- Constant Field Values
-
text
protected java.lang.String text
-
textV
protected java.util.Vector textV
-
newFont
protected boolean newFont
-
buf
protected int buf
-
doubleBuf
protected int doubleBuf
-
vSpace
protected int vSpace
-
textColor
protected java.awt.Color textColor
-
-
Constructor Detail
-
ZGSimpleTextWrap
public ZGSimpleTextWrap()
Creates a new TextDisplay Component, with the given text.
-
ZGSimpleTextWrap
public ZGSimpleTextWrap(java.lang.String text)
Creates a new TextDisplay Component, with the given text.
-
ZGSimpleTextWrap
public ZGSimpleTextWrap(java.lang.String text, java.awt.Color textColor)Creates a new TextDisplay Component, with the given text.
-
ZGSimpleTextWrap
public ZGSimpleTextWrap(java.lang.String text, int hAlignment)Creates a new TextDisplay Component, with the given text.
-
ZGSimpleTextWrap
public ZGSimpleTextWrap(java.lang.String text, int hAlignment, java.awt.Color controlTextColor)
-
-
Method Detail
-
setAlignment
public void setAlignment(int hAlignment)
Sets the current hAlignment. Possible values areZGTextWrap.LEFT,ZGTextWrap.CENTER, andZGTextWrap.RIGHT.- Parameters:
hAlignment- the hAlignment to be set.- Throws:
java.lang.IllegalArgumentException- if an improper value forhAlignmentis given.- See Also:
com.zerog.util.ZGTextWrap#getAlignment
-
getAlignment
public int getAlignment()
Gets the current hAlignment. Possible values areZGTextWrap.LEFT,ZGTextWrap.CENTER, andZGTextWrap.RIGHT.- See Also:
com.zerog.util.ZGTextWrap#setAlignment
-
setWidth
public void setWidth(int width)
Sets the width (around which text will be wrapped) for this component.
-
update
public void update(java.awt.Graphics g)
Updates the component. This method is called in response to a call to repaint. You can assume that the background is not cleared.- Overrides:
updatein classjava.awt.Component- Parameters:
g- the specified Graphics window- See Also:
paint(java.awt.Graphics)
-
setBounds
public void setBounds(int x, int y, int width, int height)- Overrides:
setBoundsin classjava.awt.Component
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
- Overrides:
getMinimumSizein classjava.awt.Component
-
getSize
public java.awt.Dimension getSize()
- Overrides:
getSizein classjava.awt.Component
-
getMaximumSize
public java.awt.Dimension getMaximumSize()
- Overrides:
getMaximumSizein classjava.awt.Component
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Overrides:
getPreferredSizein classjava.awt.Component
-
parseText
public int parseText()
Parses the text into a vector of individual lines of text based on the current width of the component. Returns an int representing the height of the component based on the number of lines to be displayed and the current font.
-
paint
public void paint(java.awt.Graphics g1)
Paints this component. This method is called when the contents of the component should be painted in response to the component first being shown or damage needing repair. The clip rectangle in the Graphics parameter will be set to the area which needs to be painted. For performance reasons, Components with zero width or height aren't considered to need painting when they are first shown, and also aren't considered to need repair.- Overrides:
paintin classjava.awt.Component- Parameters:
g- The graphics context to use for painting.
-
setSize
public void setSize(int width, int height)- Overrides:
setSizein classjava.awt.Component
-
getStringWidth
public int getStringWidth(java.lang.String str, java.awt.FontMetrics fm)
-
getText
public java.lang.String getText()
-
getComponentID
public java.lang.String getComponentID()
-
setComponentID
public void setComponentID(java.lang.String component_id)
-
-