Package com.zerog.awt

Class ZGSimpleTextWrap

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

    public class ZGSimpleTextWrap
    extends java.awt.Component
    ZGSimpleTextWrap: 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
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int buf  
      static int CENTER  
      protected int doubleBuf  
      static int LEFT  
      protected boolean newFont  
      static int RIGHT  
      protected java.lang.String text  
      protected java.awt.Color textColor  
      protected java.util.Vector textV  
      protected int vSpace  
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • 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
      int getAlignment()
      Gets the current hAlignment.
      java.lang.String getComponentID()  
      java.awt.Dimension getMaximumSize()  
      java.awt.Dimension getMinimumSize()  
      java.awt.Dimension getPreferredSize()  
      java.awt.Dimension getSize()  
      int getStringWidth​(java.lang.String str, java.awt.FontMetrics fm)  
      java.lang.String getText()  
      void paint​(java.awt.Graphics g1)
      Paints this component.
      int parseText()
      Parses the text into a vector of individual lines of text based on the current width of the component.
      void setAlignment​(int hAlignment)
      Sets the current hAlignment.
      void setBounds​(int x, int y, int width, int height)  
      void setComponentID​(java.lang.String component_id)  
      void setSize​(int width, int height)  
      void setWidth​(int width)
      Sets the width (around which text will be wrapped) for this component.
      void update​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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 are ZGTextWrap.LEFT, ZGTextWrap.CENTER, and ZGTextWrap.RIGHT.
        Parameters:
        hAlignment - the hAlignment to be set.
        Throws:
        java.lang.IllegalArgumentException - if an improper value for hAlignment is given.
        See Also:
        com.zerog.util.ZGTextWrap#getAlignment
      • getAlignment

        public int getAlignment()
        Gets the current hAlignment. Possible values are ZGTextWrap.LEFT, ZGTextWrap.CENTER, and ZGTextWrap.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:
        update in class java.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:
        setBounds in class java.awt.Component
      • getMinimumSize

        public java.awt.Dimension getMinimumSize()
        Overrides:
        getMinimumSize in class java.awt.Component
      • getSize

        public java.awt.Dimension getSize()
        Overrides:
        getSize in class java.awt.Component
      • getMaximumSize

        public java.awt.Dimension getMaximumSize()
        Overrides:
        getMaximumSize in class java.awt.Component
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        Overrides:
        getPreferredSize in class java.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:
        paint in class java.awt.Component
        Parameters:
        g - The graphics context to use for painting.
      • setSize

        public void setSize​(int width,
                            int height)
        Overrides:
        setSize in class java.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)