@Override public void handleEvent(DataRetrievalEvent evt) { switch (evt.getType()) { case COMPLETED: DrawingMode mode = (DrawingMode) instructions.get(DrawingInstruction.MODE); if (mode == DrawingMode.ARC) { int maxDataValue = IntervalTrack.getMaxValue(evt.getData()); Range range = (Range) instructions.get(DrawingInstruction.RANGE); addInstruction( DrawingInstruction.AXIS_RANGE, new AxisRange(range, new Range(0, (int) Math.round(Math.log(maxDataValue))))); } break; } super.handleEvent(evt); }
private void renderArcMode(Graphics2D g2, GraphPaneAdapter gp, Resolution r) { ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); Color bgcolor = cs.getColor(ColourKey.OPAQUE_GRAPH); AxisRange axisRange = (AxisRange) instructions.get(DrawingInstruction.AXIS_RANGE); if (r == Resolution.HIGH) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gp.setXRange(axisRange.getXRange()); gp.setYRange(axisRange.getYRange()); for (Record record : data) { Interval inter = ((IntervalRecord) record).getInterval(); int arcLength = inter.getLength(); double arcHeight = Math.log((double) arcLength); double rectWidth = arcLength * gp.getUnitWidth(); double rectHeight = arcHeight * 2 * gp.getUnitHeight(); double xOrigin = gp.transformXPos(inter.getStart()); double yOrigin = gp.transformYPos(arcHeight); g2.setColor(bgcolor); g2.draw(new Arc2D.Double(xOrigin, yOrigin, rectWidth, rectHeight, -180, -180, Arc2D.OPEN)); } } }