public void plot(AbstractDrawer draw, Color[] c) { if (!visible) return; boolean monoColor = false; if (c.length == 1) { monoColor = true; } else if (c.length != XY.length) { throw new IllegalArgumentException("Color array length must match length of data array. "); } draw.setLineType(AbstractDrawer.CONTINOUS_LINE); for (int i = 0; i < XY.length - 1; i++) { double[] begin = XY[i].clone(); double[] end = XY[i + 1].clone(); end[end.length - 1] = XY[i][end.length - 1]; draw.setColor(monoColor ? c[0] : c[i]); draw.drawLine(begin, end); } // System.out.println(Array.toString(XY)); if (link) { for (int i = 0; i < XY.length - 2; i++) { double[] begin = XY[i + 1].clone(); double[] end = XY[i + 1].clone(); begin[begin.length - 1] = XY[i][begin.length - 1]; draw.drawLine(begin, end); } } // System.out.println(Array.toString(XY)); }
public void plot(AbstractDrawer draw, Color c) { if (!visible) return; int cor = 0; for (int j = 0; j < z.length; j++) { if (j < z.length / 2) { color = new Color(0, j * (255 / (z.length / 2)), 255); cor = j; } else { color = new Color(255, cor * (255 / (z.length / 2)), 0); cor = (cor == 0) ? cor : cor - 1; } Cone _cone = new Cone(k, color); double h = height - j * 0.1; double r = ratio * (h / height); // semelhança de triangulos for (int i = 0; i < k + 1; i++) { _cone.setCone(i, r * Math.cos(i * theta), r * Math.sin(i * theta), z[j]); } listCone.add(j, _cone); } // Para saber se a visão do gráfico é superior, basta saber se screenCoord[1] <= 333. Do // contrário, estamos vendo o gráfico por baixo. int[] screenCoord = draw.project(new double[] {-1, -1, -1}); if (screenCoord[1] <= 333) { for (int i = 1; i < listCone.size(); i++) { for (int j = 1; j < k + 1; j++) { draw.setColor(listCone.get(i).getColor()); draw.fillPolygon( 1.0f, new double[] { listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j) }, new double[] { listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j) }, new double[] { listCone.get(i - 1).getX(j - 1), listCone.get(i - 1).getY(j - 1), listCone.get(i - 1).getZ(j - 1) }, new double[] { listCone.get(i - 1).getX(j), listCone.get(i - 1).getY(j), listCone.get(i - 1).getZ(j - 1) }); draw.setColor(new Color(0, 0, 0)); draw.drawPolygon( new double[] { listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j) }, new double[] { listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j) }, new double[] { listCone.get(i - 1).getX(j - 1), listCone.get(i - 1).getY(j - 1), listCone.get(i - 1).getZ(j - 1) }, new double[] { listCone.get(i - 1).getX(j), listCone.get(i - 1).getY(j), listCone.get(i - 1).getZ(j - 1) }); } } } else { for (int i = listCone.size() - 1; i > 0; i--) { for (int j = 1; j < k + 1; j++) { draw.setColor(listCone.get(i).getColor()); draw.fillPolygon( 1.0f, new double[] { listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j) }, new double[] { listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j) }, new double[] { listCone.get(i - 1).getX(j - 1), listCone.get(i - 1).getY(j - 1), listCone.get(i - 1).getZ(j - 1) }, new double[] { listCone.get(i - 1).getX(j), listCone.get(i - 1).getY(j), listCone.get(i - 1).getZ(j - 1) }); draw.setColor(new Color(0, 0, 0)); draw.drawPolygon( new double[] { listCone.get(i).getX(j), listCone.get(i).getY(j), listCone.get(i).getZ(j) }, new double[] { listCone.get(i).getX(j - 1), listCone.get(i).getY(j - 1), listCone.get(i).getZ(j) }, new double[] { listCone.get(i - 1).getX(j - 1), listCone.get(i - 1).getY(j - 1), listCone.get(i - 1).getZ(j - 1) }, new double[] { listCone.get(i - 1).getX(j), listCone.get(i - 1).getY(j), listCone.get(i - 1).getZ(j - 1) }); } } } listCone.clear(); }