Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
CH.ifa.draw.figures.NumberTextFigure Class Reference

A TextFigure specialized to edit numbers. More...

Inheritance diagram for CH.ifa.draw.figures.NumberTextFigure:
Inheritance graph
[legend]
Collaboration diagram for CH.ifa.draw.figures.NumberTextFigure:
Collaboration graph
[legend]

List of all members.

Public Member Functions

int overlayColumns ()
 Gets the number of columns to be used by the text overlay.
int overlayRows ()
 Gets the number of rows to be overlaid when the figure is edited.
int getValue ()
 Gets the numerical value of the contained text.
void setValue (int value)
 Sets the numberical value of the contained text.
void moveBy (int x, int y)
void basicDisplayBox (Point newOrigin, Point newCorner)
Rectangle displayBox ()
Rectangle textDisplayBox ()
boolean readOnly ()
 Tests whether this figure is read only.
void setReadOnly (boolean isReadOnly)
 Sets the read only status of the text figure.
Font getFont ()
 Gets the font.
void setFont (Font newFont)
 Sets the font.
void changed ()
 Updates the location whenever the figure changes itself.
Object getAttribute (String name)
 A text figure understands the "FontSize", "FontStyle", "FontName" and "TextAlign" attributes.
void setAttribute (String name, Object value)
 A text figure understands the "FontSize", "FontStyle", "FontName" and "Align" attributes.
String getText ()
 Gets the text shown by the text figure.
void setText (String newText)
 Sets the text shown by the text figure.
boolean acceptsTyping ()
 Tests whether the figure accepts typing.
void drawBackground (Graphics g)
 Draws the background of the figure.
void drawFrame (Graphics g)
 Draws the frame of the figure.
Vector handles ()
void write (StorableOutput dw)
void read (StorableInput dr) throws IOException
void connect (Figure figure)
void figureChanged (FigureChangeEvent e)
void figureRemoved (FigureChangeEvent e)
void figureRequestRemove (FigureChangeEvent e)
void figureInvalidated (FigureChangeEvent e)
void figureRequestUpdate (FigureChangeEvent e)
void release ()
void disconnect ()
 Disconnects the text figure.
void draw (Graphics g, boolean showGuides)
 Draws the figure in the given graphics.
Color getFillColor ()
 Gets the fill color of a figure.
Color getFrameColor ()
 Gets the frame color of a figure.
Object defaultAttribute (String name)
String getMap ()

Static Public Member Functions

static Font createCurrentFont ()
 Creates the current font to be used for new text figures.
static void setCurrentFontName (String name)
 Sets the current font name.
static void setCurrentFontSize (int size)
 Sets the current font size.
static void setCurrentFontStyle (int style)
 Sets the current font style.
static Object getDefaultAttribute (String name)
 Gets a the default value for a named attribute.

Protected Member Functions

void basicMoveBy (int x, int y)
void updateLocation ()
 Updates the location relative to the connected figure.

Private Attributes

int numberTextFigureSerializedDataVersion = 1

Static Private Attributes

static final long serialVersionUID = -4056859232918336475L

Detailed Description

A TextFigure specialized to edit numbers.

Definition at line 17 of file NumberTextFigure.java.


Member Function Documentation

boolean CH.ifa.draw.figures.TextFigure.acceptsTyping ( ) [inline, inherited]

Tests whether the figure accepts typing.

Definition at line 211 of file TextFigure.java.

                                   {
        return !fIsReadOnly;
    }
void CH.ifa.draw.figures.TextFigure.basicDisplayBox ( Point  newOrigin,
Point  newCorner 
) [inline, inherited]

Definition at line 77 of file TextFigure.java.

                                                                  {
        fOriginX = newOrigin.x;
        fOriginY = newOrigin.y;
    }
void CH.ifa.draw.figures.TextFigure.basicMoveBy ( int  x,
int  y 
) [inline, protected, inherited]

Definition at line 72 of file TextFigure.java.

                                             {
        fOriginX += x;
        fOriginY += y;
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.TextFigure.changed ( ) [inline, inherited]

Updates the location whenever the figure changes itself.

Definition at line 125 of file TextFigure.java.

                          {
        super.changed();
        updateLocation();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.TextFigure.connect ( Figure  figure) [inline, inherited]

Definition at line 343 of file TextFigure.java.

                                       {
        if (fObservedFigure != null)
            fObservedFigure.removeFigureChangeListener(this);

        fObservedFigure = figure;
        fLocator = new OffsetLocator(figure.connectedTextLocator(this));
        fObservedFigure.addFigureChangeListener(this);
        setAttribute("observed.figure", fObservedFigure);
        updateLocation();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Font CH.ifa.draw.figures.TextFigure.createCurrentFont ( ) [inline, static, inherited]

Creates the current font to be used for new text figures.

Definition at line 405 of file TextFigure.java.

Here is the caller graph for this function:

Object CH.ifa.draw.figures.AttributeFigure.defaultAttribute ( String  name) [inline, inherited]

Definition at line 135 of file AttributeFigure.java.

                                                {
       return getDefaultAttribute(name);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.disconnect ( ) [inline, inherited]

Disconnects the text figure.

Definition at line 394 of file TextFigure.java.

                             {
        fObservedFigure.removeFigureChangeListener(this);
        fObservedFigure = null;
        fLocator = null;
        setAttribute("observed.figure", null);
    }

Here is the call graph for this function:

Rectangle CH.ifa.draw.figures.TextFigure.displayBox ( ) [inline, inherited]

Definition at line 82 of file TextFigure.java.

                                  {
        Dimension extent = textExtent();
        return new Rectangle(fOriginX, fOriginY, extent.width, extent.height);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.AttributeFigure.draw ( Graphics  g,
boolean  showGuides 
) [inline, inherited]

Draws the figure in the given graphics.

Draw is a template method calling drawBackground followed by drawFrame.

Definition at line 48 of file AttributeFigure.java.

                                                     {
        Color fill = getFillColor();
        if (!ColorMap.getColorMap().isTransparent(fill)) {
            g.setColor(fill);
            drawBackground(g);
        }
        Color frame = getFrameColor();
        if (!ColorMap.getColorMap().isTransparent(frame)) {
            g.setColor(frame);
            drawFrame(g);
        }
       if (showGuides) {
           drawURL(g);
       }
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.drawBackground ( Graphics  g) [inline, inherited]

Draws the background of the figure.

See also:
draw

Reimplemented from CH.ifa.draw.figures.AttributeFigure.

Definition at line 215 of file TextFigure.java.

                                           {
        Rectangle r = displayBox();
        g.fillRect(r.x, r.y, r.width, r.height);
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.drawFrame ( Graphics  g) [inline, inherited]

Draws the frame of the figure.

See also:
draw

Reimplemented from CH.ifa.draw.figures.AttributeFigure.

Definition at line 220 of file TextFigure.java.

                                      {
        g.setFont(fFont);
        g.setColor((Color) getAttribute("TextColor"));
        FontMetrics metrics = g.getFontMetrics(fFont);
       StringTokenizer st = new StringTokenizer(fText, "\n");
       Dimension d = textExtent();
       
       int orgy = fOriginY;
       while (st.hasMoreTokens()) {
           String t = st.nextToken();
           int xpos = fOriginX;
           if (fAlign == TEXTALIGN_RIGHT) {
              xpos += d.width - metrics.stringWidth(t);
           } else if (fAlign == TEXTALIGN_CENTRE) {
              xpos += (d.width - metrics.stringWidth(t)) / 2;
           }
           g.drawString(t, xpos, orgy + metrics.getAscent());
           orgy += metrics.getHeight();
       }
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.figureChanged ( FigureChangeEvent  e) [inline, inherited]

Definition at line 354 of file TextFigure.java.

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.figureInvalidated ( FigureChangeEvent  e) [inline, inherited]

Definition at line 364 of file TextFigure.java.

{}
void CH.ifa.draw.figures.TextFigure.figureRemoved ( FigureChangeEvent  e) [inline, inherited]

Definition at line 358 of file TextFigure.java.

                                                   {
        if (listener() != null)
            listener().figureRequestRemove(new FigureChangeEvent(this));
    }
void CH.ifa.draw.figures.TextFigure.figureRequestRemove ( FigureChangeEvent  e) [inline, inherited]

Definition at line 363 of file TextFigure.java.

{}
void CH.ifa.draw.figures.TextFigure.figureRequestUpdate ( FigureChangeEvent  e) [inline, inherited]

Definition at line 365 of file TextFigure.java.

{}
Object CH.ifa.draw.figures.TextFigure.getAttribute ( String  name) [inline, inherited]

A text figure understands the "FontSize", "FontStyle", "FontName" and "TextAlign" attributes.

Definition at line 134 of file TextFigure.java.

                                            {
        Font font = getFont();
        if (name.equals("FontSize"))
            return new Integer(font.getSize());
        if (name.equals("FontStyle"))
            return new Integer(font.getStyle());
        if (name.equals("FontName"))
            return font.getName();
       if (name.equals("TextAlign")) {
           switch (fAlign) {
           default: return "Left";
           case TEXTALIGN_CENTRE: return "Centre";
           case TEXTALIGN_RIGHT: return "Right";
           }
       }
        return super.getAttribute(name);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static Object CH.ifa.draw.figures.AttributeFigure.getDefaultAttribute ( String  name) [inline, static, inherited]

Gets a the default value for a named attribute.

See also:
getAttribute

Definition at line 129 of file AttributeFigure.java.

                                                          {
        if (fgDefaultAttributes == null)
            initializeAttributes();
        return fgDefaultAttributes.get(name);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Color CH.ifa.draw.figures.AttributeFigure.getFillColor ( ) [inline, inherited]

Gets the fill color of a figure.

This is a convenience method.

See also:
getAttribute

Definition at line 97 of file AttributeFigure.java.

                                {
        return (Color) getAttribute("FillColor");
    }

Here is the caller graph for this function:

Font CH.ifa.draw.figures.TextFigure.getFont ( ) [inline, inherited]

Gets the font.

Definition at line 108 of file TextFigure.java.

                          {
        return fFont;
    }

Here is the caller graph for this function:

Gets the frame color of a figure.

This is a convenience method.

See also:
getAttribute

Definition at line 106 of file AttributeFigure.java.

                                 {
        return (Color) getAttribute("FrameColor");
    }

Here is the caller graph for this function:

String CH.ifa.draw.figures.AttributeFigure.getMap ( ) [inline, inherited]
String CH.ifa.draw.figures.TextFigure.getText ( ) [inline, inherited]

Gets the text shown by the text figure.

Definition at line 192 of file TextFigure.java.

                            {
        return fText;
    }

Here is the caller graph for this function:

Gets the numerical value of the contained text.

return the value or 0 in the case of an illegal number format.

Definition at line 41 of file NumberTextFigure.java.

                          {
        int value = 0;
        try {
            value = Integer.parseInt(getText());
        } catch (NumberFormatException e) {
            value = 0;
        }
        return value;
    }

Here is the call graph for this function:

Vector CH.ifa.draw.figures.TextFigure.handles ( ) [inline, inherited]

Definition at line 294 of file TextFigure.java.

                            {
        Vector handles = new Vector();
        handles.addElement(new NullHandle(this, RelativeLocator.northWest()));
        handles.addElement(new NullHandle(this, RelativeLocator.northEast()));
        handles.addElement(new NullHandle(this, RelativeLocator.southEast()));
        handles.addElement(new FontSizeHandle(this, RelativeLocator.southWest()));
        return handles;
    }
void CH.ifa.draw.figures.TextFigure.moveBy ( int  x,
int  y 
) [inline, inherited]

Definition at line 64 of file TextFigure.java.

                                     {
        willChange();
        basicMoveBy(x, y);
        if (fLocator != null)
            fLocator.moveBy(x, y);
        changed();
    }

Here is the call graph for this function:

Gets the number of columns to be used by the text overlay.

See also:
FloatingTextField

Reimplemented from CH.ifa.draw.figures.TextFigure.

Definition at line 29 of file NumberTextFigure.java.

                                {
        return Math.max(4, getText().length());
    }

Here is the call graph for this function:

Gets the number of rows to be overlaid when the figure is edited.

Reimplemented from CH.ifa.draw.figures.TextFigure.

Definition at line 33 of file NumberTextFigure.java.

                             {
       return 1;
    }
void CH.ifa.draw.figures.TextFigure.read ( StorableInput  dr) throws IOException [inline, inherited]

Definition at line 316 of file TextFigure.java.

                                                          {
        super.read(dr);
        markDirty();
        fOriginX = dr.readInt();
        fOriginY = dr.readInt();
        fText = dr.readString();
        fFont = new Font(dr.readString(), dr.readInt(), dr.readInt());
        fIsReadOnly = dr.readBoolean();

        fObservedFigure = (Figure)dr.readStorable();
        if (fObservedFigure != null) {
            setAttribute("observed.figure", fObservedFigure);
            fObservedFigure.addFigureChangeListener(this);
        }
        fLocator = (OffsetLocator)dr.readStorable();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean CH.ifa.draw.figures.TextFigure.readOnly ( ) [inline, inherited]

Tests whether this figure is read only.

Definition at line 94 of file TextFigure.java.

                              {
        return fIsReadOnly;
    }
void CH.ifa.draw.figures.TextFigure.release ( ) [inline, inherited]

Definition at line 385 of file TextFigure.java.

                          {
        super.release();
        if (fObservedFigure != null)
            fObservedFigure.removeFigureChangeListener(this);
    }

Here is the caller graph for this function:

void CH.ifa.draw.figures.TextFigure.setAttribute ( String  name,
Object  value 
) [inline, inherited]

A text figure understands the "FontSize", "FontStyle", "FontName" and "Align" attributes.

Definition at line 156 of file TextFigure.java.

                                                        {
        Font font = getFont();
        if (name.equals("FontSize")) {
            Integer s = (Integer)value;
            setFont(new Font(font.getName(), font.getStyle(), s.intValue()) );
        }
        else if (name.equals("FontStyle")) {
            Integer s = (Integer)value;
            int style = font.getStyle();
            if (s.intValue() == Font.PLAIN)
                style = font.PLAIN;
            else
                style = style ^ s.intValue();
            setFont(new Font(font.getName(), style, font.getSize()) );
        }
        else if (name.equals("FontName")) {
            String n = (String)value;
            setFont(new Font(n, font.getStyle(), font.getSize()) );
        }
       else if (name.equals("TextAlign")) {
            String n = (String)value;
           if (n.equals("Centre"))
              fAlign = TEXTALIGN_CENTRE;
           else if (n.equals("Right"))
              fAlign = TEXTALIGN_RIGHT;
           else
              fAlign = TEXTALIGN_LEFT;
            changed();
       }
        else
            super.setAttribute(name, value);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void CH.ifa.draw.figures.TextFigure.setCurrentFontName ( String  name) [inline, static, inherited]

Sets the current font name.

Definition at line 412 of file TextFigure.java.

                                                       {
        fgCurrentFontName = name;
    }
static void CH.ifa.draw.figures.TextFigure.setCurrentFontSize ( int  size) [inline, static, inherited]

Sets the current font size.

Definition at line 419 of file TextFigure.java.

Here is the call graph for this function:

static void CH.ifa.draw.figures.TextFigure.setCurrentFontStyle ( int  style) [inline, static, inherited]

Sets the current font style.

Definition at line 426 of file TextFigure.java.

                                                      {
        fgCurrentFontStyle = style;
    }
void CH.ifa.draw.figures.TextFigure.setFont ( Font  newFont) [inline, inherited]

Sets the font.

Definition at line 115 of file TextFigure.java.

                                      {
        willChange();
        fFont = newFont;
        markDirty();
        changed();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.TextFigure.setReadOnly ( boolean  isReadOnly) [inline, inherited]

Sets the read only status of the text figure.

Definition at line 101 of file TextFigure.java.

                                                {
        fIsReadOnly = isReadOnly;
    }
void CH.ifa.draw.figures.TextFigure.setText ( String  newText) [inline, inherited]

Sets the text shown by the text figure.

Definition at line 199 of file TextFigure.java.

                                        {
        if (!newText.equals(fText)) {
            willChange();
            fText = new String(newText);
            markDirty();
            changed();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.NumberTextFigure.setValue ( int  value) [inline]

Sets the numberical value of the contained text.

Definition at line 54 of file NumberTextFigure.java.

                                    {
        setText(Integer.toString(value));
    }

Here is the call graph for this function:

Rectangle CH.ifa.draw.figures.TextFigure.textDisplayBox ( ) [inline, inherited]

Definition at line 87 of file TextFigure.java.

                                      {
        return displayBox();
    }

Here is the call graph for this function:

void CH.ifa.draw.figures.TextFigure.updateLocation ( ) [inline, protected, inherited]

Updates the location relative to the connected figure.

The TextFigure is centered around the located point.

Definition at line 371 of file TextFigure.java.

                                    {
        if (fLocator != null) {
            Point p = fLocator.locate(fObservedFigure);
            p.x -= size().width/2 + fOriginX;
            p.y -= size().height/2 + fOriginY;

            if (p.x != 0 || p.y != 0) {
                willChange();
                basicMoveBy(p.x, p.y);
                changed();
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.figures.TextFigure.write ( StorableOutput  dw) [inline, inherited]

Definition at line 303 of file TextFigure.java.

                                         {
        super.write(dw);
        dw.writeInt(fOriginX);
        dw.writeInt(fOriginY);
        dw.writeString(fText);
        dw.writeString(fFont.getName());
        dw.writeInt(fFont.getStyle());
        dw.writeInt(fFont.getSize());
        dw.writeBoolean(fIsReadOnly);
        dw.writeStorable(fObservedFigure);
        dw.writeStorable(fLocator);
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 23 of file NumberTextFigure.java.

final long CH.ifa.draw.figures.NumberTextFigure.serialVersionUID = -4056859232918336475L [static, private]

Reimplemented from CH.ifa.draw.figures.TextFigure.

Definition at line 22 of file NumberTextFigure.java.


The documentation for this class was generated from the following file: