All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentrafficsim.draw.graphs.ContourPlotDensity Maven / Gradle / Ivy

The newest version!
package org.opentrafficsim.draw.graphs;

import java.awt.Color;

import org.djunits.unit.LinearDensityUnit;
import org.djunits.value.vdouble.scalar.LinearDensity;
import org.opentrafficsim.draw.BoundsPaintScale;
import org.opentrafficsim.draw.graphs.ContourDataSource.ContourDataType;

/**
 * Contour plot for density.
 * 

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

* @author Alexander Verbraeck * @author Peter Knoppers * @author Wouter Schakel */ public class ContourPlotDensity extends AbstractContourPlot { /** * Constructor. * @param caption String; caption * @param scheduler PlotScheduler; scheduler. * @param dataPool ContourDataSource; data pool */ public ContourPlotDensity(final String caption, final PlotScheduler scheduler, final ContourDataSource dataPool) { super(caption, scheduler, dataPool, createPaintScale(), new LinearDensity(30.0, LinearDensityUnit.PER_KILOMETER), "%.0f/km", "density %.1f veh/km"); } /** * Creates a paint scale from red, via yellow to green. * @return ContinuousColorPaintScale; paint scale */ private static BoundsPaintScale createPaintScale() { double[] boundaries = {0.0, 20.0 / 1000, 150.0 / 1000}; Color[] colorValues = BoundsPaintScale.GREEN_RED; return new BoundsPaintScale(boundaries, colorValues); } /** {@inheritDoc} */ @Override public GraphType getGraphType() { return GraphType.DENSITY_CONTOUR; } /** {@inheritDoc} */ @Override protected double scale(final double si) { return LinearDensityUnit.PER_KILOMETER.getScale().fromStandardUnit(si); } /** {@inheritDoc} */ @Override protected double getValue(final int item, final double cellLength, final double cellSpan) { return getDataPool().getTotalTime(item) / (cellLength * cellSpan); } /** {@inheritDoc} */ @Override protected ContourDataType getContourDataType() { return null; // density is present by default } /** {@inheritDoc} */ @Override public String toString() { return "ContourPlotDensity []"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy