/** * The function that controls the drawing of the graphics. * * <p>If ISEQIMAG is true, then both x and y will be incremented. * * <p>The (X, Y) coords will be: <br> * X: The 'real' value of the complex number yielded when X and Y are plugged into EQUATION. <br> * Y: The 'imaginary' value of the complex number yielded when X and Y are plugged into EQUATION. * The (X, Y) coords will be: <br> * X: The x value (which is being incremented). <br> * Y: The resulting value when X is plugged into theEQUATION. * * @param pGraphics The graphics input that will be used to draw. Assumed to be Graphics2D. */ public void paintComponent(Graphics pGraphics) { assert pGraphics instanceof Graphics2D : "Uh, Idek how this happened, but g has to be a Graphics2D..."; drawer = (Graphics2D) pGraphics; drawer.setColor(color); double[] dispBounds = grapher.components().dispBounds(); double[] stepInfo = grapher.components().stepInfo(); if (numc != null) { assert numc.size() == 2; assert numc.get(0).size() == numc.get(1).size(); for (int x = 0; x < numc.get(0).size(); x++) { double d1 = numc.get(0).get(x).toDouble(); double d2 = numc.get(1).get(x).toDouble(); if (d1 == Double.NaN) { Print.printi("d1 is " + d1 + ". Not graphing (" + d1 + ", " + d2 + ")."); } if (d2 == Double.NaN) { Print.printi("d2 is " + d2 + ". Not graphing (" + d1 + ", " + d2 + ")."); } drawp(d1, d2); } } else if (equation != null) { double cStep = grapher.components().cStep(); for (double x = stepInfo[0]; x < stepInfo[1]; x += cStep) { drawl( new Complex(x), (Complex) equationsys.eval( equation.getVar(), new EquationSystem().add(grapher.components().indepVar() + "=" + x)), new Complex(x + cStep), (Complex) equationsys.eval( equation.getVar(), new EquationSystem().add(grapher.components().indepVar() + "=" + (x + cStep))), false); } } else { drawl(0d, dispBounds[1], 0d, dispBounds[3], true); // axis. drawl(dispBounds[0], 0d, dispBounds[2], 0d, true); // axis. } }
/** Note that this doesnt consider drawer. TODO: JAVADOC */ @Override public boolean equals(Object pObj) { if (pObj == null || !(pObj instanceof DisplayComponent)) return false; if (this == pObj) return true; DisplayComponent pdisp = (DisplayComponent) pObj; if (!grapher.equals(pdisp.grapher)) return false; if (equation == null ^ pdisp.equation == null) return false; if (equationsys == null ^ pdisp.equationsys == null) return false; if (numc == null ^ pdisp.numc == null) return false; if (color == null ^ pdisp.color == null) return false; return (equation == null || equation.equals(pdisp.equation)) && (equationsys == null || equationsys.equals(pdisp.equationsys)) && (numc == null || numc.equals(pdisp.numc)) && (color == null || color.equals(pdisp.color)); }
@Override public String toFullString(int idtLvl) { String ret = indent(idtLvl) + "DisplayComponent:"; ret += "\n" + indent(idtLvl + 1) + "EquationSystem for Graphing:\n"; ret += equationsys == null ? indentE(idtLvl + 2) + "" : equationsys.toFullString(idtLvl + 2); ret += "\n" + indent(idtLvl + 1) + "Equation to Graph:\n"; ret += equation == null ? indentE(idtLvl + 2) + "" : equation.toFullString(idtLvl + 2); ret += "\n" + indent(idtLvl + 1) + "NumberCollection to Graph:\n"; // assert numc.size() == 2; // assert numc.get(0).size() == numc.get(1).size(); ret += numc == null ? indent(idtLvl + 2) + "" : numc.get(0).toFullString(idtLvl + 2) + "\n" + numc.get(1).toFullString(idtLvl + 2); ret += "\n" + indent(idtLvl + 1) + "Color:\n" + indentE(idtLvl + 2) + color; ret += "\n" + indentE(idtLvl + 1); return ret; }