Logo Search packages:      
Sourcecode: wims version File versions

boolean ptolemy::plot::PlotBox::_parseLine ( String  line  )  [inline, protected]

Parse a line that gives plotting information. In this base class, only lines pertaining to the title and labels are processed. Everything else is ignored. Return true if the line is recognized. It is not synchronized, so its caller should be.

Parameters:
line A line of text.

Reimplemented in ptolemy::plot::Histogram, and ptolemy::plot::Plot.

Definition at line 2568 of file PlotBox.java.

References _grid, _usecolor, _wrap, _xlog, _ylog, setTitle(), setXLabel(), setXRange(), setYLabel(), and setYRange().

Referenced by parseFile(), and read().

                                              {
        // If you modify this method, you should also modify write()
        // We convert the line to lower case so that the command
        // names are case insensitive.
        String lcLine = line.toLowerCase();

        if (lcLine.startsWith("#")) {
            // comment character
            return true;
        } else if (lcLine.startsWith("titletext:")) {
            setTitle((line.substring(10)).trim());
            return true;
        } else if (lcLine.startsWith("title:")) {
            // Tolerate alternative tag.
            setTitle((line.substring(6)).trim());
            return true;
        } else if (lcLine.startsWith("xlabel:")) {
            setXLabel((line.substring(7)).trim());
            return true;
        } else if (lcLine.startsWith("ylabel:")) {
            setYLabel((line.substring(7)).trim());
            return true;
        } else if (lcLine.startsWith("xrange:")) {
            int comma = line.indexOf(",", 7);

            if (comma > 0) {
                String min = (line.substring(7, comma)).trim();
                String max = (line.substring(comma + 1)).trim();

                try {
                    Double dmin = Double.valueOf(min);
                    Double dmax = Double.valueOf(max);
                    setXRange(dmin.doubleValue(), dmax.doubleValue());
                } catch (NumberFormatException e) {
                    // ignore if format is bogus.
                }
            }

            return true;
        } else if (lcLine.startsWith("yrange:")) {
            int comma = line.indexOf(",", 7);

            if (comma > 0) {
                String min = (line.substring(7, comma)).trim();
                String max = (line.substring(comma + 1)).trim();

                try {
                    Double dmin = Double.valueOf(min);
                    Double dmax = Double.valueOf(max);
                    setYRange(dmin.doubleValue(), dmax.doubleValue());
                } catch (NumberFormatException e) {
                    // ignore if format is bogus.
                }
            }

            return true;
        } else if (lcLine.startsWith("xticks:")) {
            // example:
            // XTicks "label" 0, "label" 1, "label" 3
            _parsePairs(line.substring(7), true);
            return true;
        } else if (lcLine.startsWith("yticks:")) {
            // example:
            // YTicks "label" 0, "label" 1, "label" 3
            _parsePairs(line.substring(7), false);
            return true;
        } else if (lcLine.startsWith("xlog:")) {
            if (lcLine.indexOf("off", 5) >= 0) {
                _xlog = false;
            } else {
                _xlog = true;
            }

            return true;
        } else if (lcLine.startsWith("ylog:")) {
            if (lcLine.indexOf("off", 5) >= 0) {
                _ylog = false;
            } else {
                _ylog = true;
            }

            return true;
        } else if (lcLine.startsWith("grid:")) {
            if (lcLine.indexOf("off", 5) >= 0) {
                _grid = false;
            } else {
                _grid = true;
            }

            return true;
        } else if (lcLine.startsWith("wrap:")) {
            if (lcLine.indexOf("off", 5) >= 0) {
                _wrap = false;
            } else {
                _wrap = true;
            }

            return true;
        } else if (lcLine.startsWith("color:")) {
            if (lcLine.indexOf("off", 6) >= 0) {
                _usecolor = false;
            } else {
                _usecolor = true;
            }

            return true;
        }

        return false;
    }


Generated by  Doxygen 1.6.0   Back to index