ErrorBar for datapoints.
| 1791 | * ErrorBar for datapoints. |
| 1792 | */ |
| 1793 | class ErrorBar implements Drawable { |
| 1794 | double x, y, delx, dely; // the position and uncertainty of the data point |
| 1795 | int tick = 3; |
| 1796 | |
| 1797 | ErrorBar(double _x, double _y, double _delx, double _dely) { |
| 1798 | x = _x; |
| 1799 | y = _y; |
| 1800 | delx = _delx; |
| 1801 | dely = _dely; |
| 1802 | } |
| 1803 | |
| 1804 | /** |
| 1805 | * Draws the error bars for a data point. |
| 1806 | * |
| 1807 | * @param panel |
| 1808 | * @param g |
| 1809 | */ |
| 1810 | @Override |
| 1811 | public void draw(DrawingPanel panel, Graphics g) { |
| 1812 | // changed by D.Brown |
| 1813 | if (Double.isNaN(y)) { |
| 1814 | return; |
| 1815 | } |
| 1816 | int xpix = panel.xToPix(x); |
| 1817 | int xpix1 = panel.xToPix(x - delx); |
| 1818 | int xpix2 = panel.xToPix(x + delx); |
| 1819 | int ypix = panel.yToPix(y); |
| 1820 | int ypix1 = panel.yToPix(y - dely); |
| 1821 | int ypix2 = panel.yToPix(y + dely); |
| 1822 | g.setColor(errorBarColor); |
| 1823 | g.drawLine(xpix1, ypix, xpix2, ypix); |
| 1824 | g.drawLine(xpix, ypix1, xpix, ypix2); |
| 1825 | g.drawLine(xpix1, ypix - tick, xpix1, ypix + tick); |
| 1826 | g.drawLine(xpix2, ypix - tick, xpix2, ypix + tick); |
| 1827 | g.drawLine(xpix - tick, ypix1, xpix + tick, ypix1); |
| 1828 | g.drawLine(xpix - tick, ypix2, xpix + tick, ypix2); |
| 1829 | } |
| 1830 | |
| 1831 | } |
| 1832 | |
| 1833 | /** |
| 1834 | * Returns the XML.ObjectLoader for this class. |
nothing calls this directly
no outgoing calls
no test coverage detected