protected void drawValues(GraphicsContext g, int width, int height) { ChartContentProvider content = getContentProvider(); ChartColorProvider colors = getColorProvider(); int itemOffset = getItemWindow().getOffset(); int itemCount = getItemWindow().getCount(); int seriesOffset = 0; int layerOffset = 0; float itemWidth = getItemWidth(); double minValue = getMinValue(); float base = (float) -minValue * getValueScale(); Range itemSelection = getItemSelection(); ColorRGBA seriesColor = colors.getSeriesColor(layerOffset, seriesOffset); for (int i = 0; i < itemCount; i++) { // FIXME: 0.25f and 0.5f should be variables/constants float x0 = (float) i * itemWidth + 0.25f * itemWidth; float x1 = x0 + 0.5f * itemWidth; float y0 = base; float y1 = base; double value = content.getValue(layerOffset, seriesOffset, i + itemOffset); if (!Double.isNaN(value)) { float scaledValue; scaledValue = (float) value * getValueScale(); y1 = y0 + scaledValue; if (itemSelection.contains(itemOffset + i)) { g.setForeground(seriesColor); } else { g.setForeground(deselectedColor); } g.fillRectangle2D(x0, y0, x1, y1); y0 = y1; } else { // Loss could be marked in this else clause, // if desired in the future } } }
protected void drawAxesTicks(GraphicsContext g, int width, int height) { int itemTickStep = getItemTickStep(); int itemOffset = getItemWindow().getOffset(); int itemCount = getItemWindow().getCount(); float itemWidth = getItemWidth(); float xOffset = 0.5f * itemWidth + (itemTickStep - 1 - itemOffset % itemTickStep) * itemWidth; float xStep = itemWidth * (float) itemTickStep; float xLimit = itemWidth * itemCount; float yOffset = (float) -getMinValue() * getValueScale(); float tickLength = 6.0f; g.drawTicksX(xOffset, xStep, xLimit, 6.0f / getInnerScale(height), yOffset); double maxValue = getMaxValue(); double minValue = getMinValue(); float base = (float) -minValue * getValueScale(); float yStep; final String boundsTestString = "0"; double threshold = g.getTextBounds2D(GraphicsContext.FONT_LABEL, boundsTestString).getHeight(); if (maxValue >= Math.abs(minValue)) { yStep = (float) (getAdaptiveStepSize(maxValue, height, threshold) * getValueScale()); } else { yStep = (float) (getAdaptiveStepSize(Math.abs(minValue), height, threshold) * getValueScale()); } if (getMaxValue() > 0) { // Draw positive Y ticks g.drawTicksY(base, yStep, 1.01f, tickLength, 0.0f); } if (getMinValue() < 0) { // Draw negative Y ticks g.drawTicksY(base, -yStep, -0.01f, tickLength, 0.0f); } }
public void drawWhiteEdge(Edge e) { // Graphics GraphicsContext gc = kochPanel.getGraphicsContext2D(); // Adjust edge for zoom and drag Edge e1 = edgeAfterZoomAndDrag(e); // Set line color gc.setStroke(Color.WHITE); // Set line width depending on level if (currentLevel <= 3) { gc.setLineWidth(2.0); } else if (currentLevel <= 5) { gc.setLineWidth(1.5); } else { gc.setLineWidth(1.0); } // Draw line gc.strokeLine(e1.X1, e1.Y1, e1.X2, e1.Y2); }
public void clearKochPanel() { GraphicsContext gc = kochPanel.getGraphicsContext2D(); gc.clearRect(0.0, 0.0, kpWidth, kpHeight); gc.setFill(Color.BLACK); gc.fillRect(0.0, 0.0, kpWidth, kpHeight); }