Class XYInterpolatedBlockRenderer

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, AnnotationChangeListener, LegendItemSource, XYItemRenderer, PublicCloneable

public class XYInterpolatedBlockRenderer
extends XYBlockRenderer
Renderer for blocks that are filled with bidirectionally interpolated colors. It extends a XYBlockRenderer and requires a small extension of the underlying dataset (XYInterpolatedDataset). The interpolation is performed in the drawItem method. This class imposes two constraints on the functionality of the super class: i) no BlockAnchor may be set as this is tightly related to the interpolation, and ii) only paint scales of type ColorPaintScale can be used, as the interpolation obtains pixel colors from it.

Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version 8 okt. 2018
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
Serialized Form
  • Constructor Details

    • XYInterpolatedBlockRenderer

      public XYInterpolatedBlockRenderer​(org.opentrafficsim.draw.graphs.XYInterpolatedDataset xyInterpolatedDataset)
      Parameters:
      xyInterpolatedDataset - XYInterpolatedDataset; dataset that allows retrieving surrounding value for interpolation
  • Method Details

    • setPaintScale

      public void setPaintScale​(PaintScale scale)
      throws UnsupportedOperationException if the paint scale is not of type ColorPaintScale
      Overrides:
      setPaintScale in class XYBlockRenderer
    • setBlockAnchor

      public void setBlockAnchor​(RectangleAnchor anchor)
      throws UnsupportedOperationException block anchor is governed based on interpolation
      Overrides:
      setBlockAnchor in class XYBlockRenderer
    • setInterpolate

      public final void setInterpolate​(boolean interpolate)
      Enables interpolation or not. Interpolation occurs between cell centers. Therefore the painted blocks are shifted right and up. The user of this class must provide an additional row and column of data to fill up the gaps. These values may be NaN.
      Parameters:
      interpolate - boolean; interpolate or not
    • drawItem

      public void drawItem​(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass)
      This code is partially based on the parent implementation.
      Specified by:
      drawItem in interface XYItemRenderer
      Overrides:
      drawItem in class XYBlockRenderer
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object