org.jfree.chart.util.ParamChecks Java Examples

The following examples show how to use org.jfree.chart.util.ParamChecks. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultHighLowDataset.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a new high/low/open/close dataset.
 * <p>
 * The current implementation allows only one series in the dataset.
 * This may be extended in a future version.
 *
 * @param seriesKey  the key for the series (<code>null</code> not
 *     permitted).
 * @param date  the dates (<code>null</code> not permitted).
 * @param high  the high values (<code>null</code> not permitted).
 * @param low  the low values (<code>null</code> not permitted).
 * @param open  the open values (<code>null</code> not permitted).
 * @param close  the close values (<code>null</code> not permitted).
 * @param volume  the volume values (<code>null</code> not permitted).
 */
public DefaultHighLowDataset(Comparable seriesKey, Date[] date,
        double[] high, double[] low, double[] open, double[] close,
        double[] volume) {

    ParamChecks.nullNotPermitted(seriesKey, "seriesKey");
    ParamChecks.nullNotPermitted(date, "date");
    this.seriesKey = seriesKey;
    this.date = date;
    this.high = createNumberArray(high);
    this.low = createNumberArray(low);
    this.open = createNumberArray(open);
    this.close = createNumberArray(close);
    this.volume = createNumberArray(volume);

}
 
Example #2
Source File: DatasetUtilities.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the range of values in the domain (x-values) of a dataset.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param includeInterval  determines whether or not the x-interval is taken
 *                         into account (only applies if the dataset is an
 *                         {@link IntervalXYDataset}).
 *
 * @return The range of values (possibly <code>null</code>).
 */
public static Range findDomainBounds(XYDataset dataset,
        boolean includeInterval) {

    ParamChecks.nullNotPermitted(dataset, "dataset");

    Range result;
    // if the dataset implements DomainInfo, life is easier
    if (dataset instanceof DomainInfo) {
        DomainInfo info = (DomainInfo) dataset;
        result = info.getDomainBounds(includeInterval);
    }
    else {
        result = iterateDomainBounds(dataset, includeInterval);
    }
    return result;

}
 
Example #3
Source File: CombinedDomainXYPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds a subplot with the specified weight and sends a
 * {@link PlotChangeEvent} to all registered listeners.  The weight
 * determines how much space is allocated to the subplot relative to all
 * the other subplots.
 * <P>
 * The domain axis for the subplot will be set to <code>null</code>.  You
 * must ensure that the subplot has a non-null range axis.
 *
 * @param subplot  the subplot (<code>null</code> not permitted).
 * @param weight  the weight (must be &gt;= 1).
 */
public void add(XYPlot subplot, int weight) {
    ParamChecks.nullNotPermitted(subplot, "subplot");
    if (weight <= 0) {
        throw new IllegalArgumentException("Require weight >= 1.");
    }

    // store the plot and its weight
    subplot.setParent(this);
    subplot.setWeight(weight);
    subplot.setInsets(RectangleInsets.ZERO_INSETS, false);
    subplot.setDomainAxis(null);
    subplot.addChangeListener(this);
    this.subplots.add(subplot);

    ValueAxis axis = getDomainAxis();
    if (axis != null) {
        axis.configure();
    }
    fireChangeEvent();
}
 
Example #4
Source File: CombinedRangeXYPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds a subplot with a particular weight (greater than or equal to one).
 * The weight determines how much space is allocated to the subplot
 * relative to all the other subplots.
 * <br><br>
 * You must ensure that the subplot has a non-null domain axis.  The range
 * axis for the subplot will be set to <code>null</code>.
 *
 * @param subplot  the subplot (<code>null</code> not permitted).
 * @param weight  the weight (must be 1 or greater).
 */
public void add(XYPlot subplot, int weight) {
    ParamChecks.nullNotPermitted(subplot, "subplot");
    if (weight <= 0) {
        String msg = "The 'weight' must be positive.";
        throw new IllegalArgumentException(msg);
    }

    // store the plot and its weight
    subplot.setParent(this);
    subplot.setWeight(weight);
    subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    subplot.setRangeAxis(null);
    subplot.addChangeListener(this);
    this.subplots.add(subplot);
    configureRangeAxes();
    fireChangeEvent();

}
 
Example #5
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    ParamChecks.nullNotPermitted(theme, "theme");
    currentTheme = theme;

    // here we do a check to see if the user is installing the "Legacy"
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        }
        else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
 
Example #6
Source File: DataUtilities.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the total of the values in one row of the supplied data
 * table by taking only the column numbers in the array into account.
 *
 * @param data  the table of values (<code>null</code> not permitted).
 * @param row  the row index (zero-based).
 * @param validCols the array with valid cols (zero-based).
 *
 * @return The total of the valid values in the specified row.
 *
 * @since 1.0.13
 */
public static double calculateRowTotal(Values2D data, int row,
         int[] validCols) {
    ParamChecks.nullNotPermitted(data, "data");
    double total = 0.0;
    int colCount = data.getColumnCount();
    for (int v = 0; v < validCols.length; v++) {
        int col = validCols[v];
        if (col < colCount) {
            Number n = data.getValue(row, col);
            if (n != null) {
                total += n.doubleValue();
            }
        }
    }
    return total;
}
 
Example #7
Source File: KeyToGroupMap.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Maps a key to a group.
 *
 * @param key  the key (<code>null</code> not permitted).
 * @param group  the group (<code>null</code> permitted, clears any
 *               existing mapping).
 */
public void mapKeyToGroup(Comparable key, Comparable group) {
    ParamChecks.nullNotPermitted(key, "key");
    Comparable currentGroup = getGroup(key);
    if (!currentGroup.equals(this.defaultGroup)) {
        if (!currentGroup.equals(group)) {
            int count = getKeyCount(currentGroup);
            if (count == 1) {
                this.groups.remove(currentGroup);
            }
        }
    }
    if (group == null) {
        this.keyToGroupMap.remove(key);
    }
    else {
        if (!this.groups.contains(group)) {
            if (!this.defaultGroup.equals(group)) {
                this.groups.add(group);
            }
        }
        this.keyToGroupMap.put(key, group);
    }
}
 
Example #8
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds an annotation to the specified layer and sends a
 * {@link RendererChangeEvent} to all registered listeners.
 *
 * @param annotation  the annotation (<code>null</code> not permitted).
 * @param layer  the layer (<code>null</code> not permitted).
 */
@Override
public void addAnnotation(XYAnnotation annotation, Layer layer) {
    ParamChecks.nullNotPermitted(annotation, "annotation");
    if (layer.equals(Layer.FOREGROUND)) {
        this.foregroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else if (layer.equals(Layer.BACKGROUND)) {
        this.backgroundAnnotations.add(annotation);
        annotation.addChangeListener(this);
        fireChangeEvent();
    }
    else {
        // should never get here
        throw new RuntimeException("Unknown layer.");
    }
}
 
Example #9
Source File: AxisSpace.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds space to the top, bottom, left or right edge of the plot area.
 *
 * @param space  the space (in Java2D units).
 * @param edge  the edge (<code>null</code> not permitted).
 */
public void add(double space, RectangleEdge edge) {
    ParamChecks.nullNotPermitted(edge, "edge");
    if (edge == RectangleEdge.TOP) {
        this.top += space;
    }
    else if (edge == RectangleEdge.BOTTOM) {
        this.bottom += space;
    }
    else if (edge == RectangleEdge.LEFT) {
        this.left += space;
    }
    else if (edge == RectangleEdge.RIGHT) {
        this.right += space;
    }
    else {
        throw new IllegalStateException("Unrecognised 'edge' argument.");
    }
}
 
Example #10
Source File: PeriodAxisLabelInfo.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param periodClass  the subclass of {@link RegularTimePeriod} to use
 *                     (<code>null</code> not permitted).
 * @param dateFormat  the date format (<code>null</code> not permitted).
 * @param padding  controls the space around the band (<code>null</code>
 *                 not permitted).
 * @param labelFont  the label font (<code>null</code> not permitted).
 * @param labelPaint  the label paint (<code>null</code> not permitted).
 * @param drawDividers  a flag that controls whether dividers are drawn.
 * @param dividerStroke  the stroke used to draw the dividers
 *                       (<code>null</code> not permitted).
 * @param dividerPaint  the paint used to draw the dividers
 *                      (<code>null</code> not permitted).
 */
public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat,
        RectangleInsets padding, Font labelFont, Paint labelPaint,
        boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) {
    ParamChecks.nullNotPermitted(periodClass, "periodClass");
    ParamChecks.nullNotPermitted(dateFormat, "dateFormat");
    ParamChecks.nullNotPermitted(padding, "padding");
    ParamChecks.nullNotPermitted(labelFont, "labelFont");
    ParamChecks.nullNotPermitted(labelPaint, "labelPaint");
    ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke");
    ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint");
    this.periodClass = periodClass;
    this.dateFormat = (DateFormat) dateFormat.clone();
    this.padding = padding;
    this.labelFont = labelFont;
    this.labelPaint = labelPaint;
    this.drawDividers = drawDividers;
    this.dividerStroke = dividerStroke;
    this.dividerPaint = dividerPaint;
}
 
Example #11
Source File: AxisLocation.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the location that is opposite to the supplied location.
 *
 * @param location  the location (<code>null</code> not permitted).
 *
 * @return The opposite location.
 */
public static AxisLocation getOpposite(AxisLocation location) {
    ParamChecks.nullNotPermitted(location, "location");
    AxisLocation result = null;
    if (location == AxisLocation.TOP_OR_LEFT) {
        result = AxisLocation.BOTTOM_OR_RIGHT;
    }
    else if (location == AxisLocation.TOP_OR_RIGHT) {
        result = AxisLocation.BOTTOM_OR_LEFT;
    }
    else if (location == AxisLocation.BOTTOM_OR_LEFT) {
        result = AxisLocation.TOP_OR_RIGHT;
    }
    else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
        result = AxisLocation.TOP_OR_LEFT;
    }
    else {
        throw new IllegalStateException("AxisLocation not recognised.");
    }
    return result;
}
 
Example #12
Source File: ChartEntity.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a string containing the coordinates for a given shape.  This
 * string is intended for use in an image map.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 *
 * @return The coordinates for a given shape as string.
 */
private String getPolyCoords(Shape shape) {
    ParamChecks.nullNotPermitted(shape, "shape");
    StringBuilder result = new StringBuilder();
    boolean first = true;
    float[] coords = new float[6];
    PathIterator pi = shape.getPathIterator(null, 1.0);
    while (!pi.isDone()) {
        pi.currentSegment(coords);
        if (first) {
            first = false;
            result.append((int) coords[0]);
            result.append(",").append((int) coords[1]);
        }
        else {
            result.append(",");
            result.append((int) coords[0]);
            result.append(",");
            result.append((int) coords[1]);
        }
        pi.next();
    }
    return result.toString();
}
 
Example #13
Source File: StandardXYURLGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructor that overrides all the defaults
 *
 * @param prefix  the prefix to the URL (<code>null</code> not permitted).
 * @param seriesParameterName  the name of the series parameter to go in
 *                             each URL (<code>null</code> not permitted).
 * @param itemParameterName  the name of the item parameter to go in each
 *                           URL (<code>null</code> not permitted).
 */
public StandardXYURLGenerator(String prefix, String seriesParameterName,
        String itemParameterName) {
    ParamChecks.nullNotPermitted(prefix, "prefix");
    ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName");
    ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName");
    this.prefix = prefix;
    this.seriesParameterName = seriesParameterName;
    this.itemParameterName = itemParameterName;
}
 
Example #14
Source File: Range.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Shifts the range by the specified amount.
 *
 * @param base  the base range (<code>null</code> not permitted).
 * @param delta  the shift amount.
 * @param allowZeroCrossing  a flag that determines whether or not the
 *                           bounds of the range are allowed to cross
 *                           zero after adjustment.
 *
 * @return A new range.
 */
public static Range shift(Range base, double delta,
                          boolean allowZeroCrossing) {
    ParamChecks.nullNotPermitted(base, "base");
    if (allowZeroCrossing) {
        return new Range(base.getLowerBound() + delta,
                base.getUpperBound() + delta);
    }
    else {
        return new Range(shiftWithNoZeroCrossing(base.getLowerBound(),
                delta), shiftWithNoZeroCrossing(base.getUpperBound(),
                delta));
    }
}
 
Example #15
Source File: CategoryItemEntity.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new entity instance for an item in the specified dataset.
 *
 * @param area  the 'hotspot' area (<code>null</code> not permitted).
 * @param toolTipText  the tool tip text.
 * @param urlText  the URL text.
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param columnKey  the column key (<code>null</code> not permitted).
 *
 * @since 1.0.6
 */
public CategoryItemEntity(Shape area, String toolTipText, String urlText,
        CategoryDataset dataset, Comparable rowKey, Comparable columnKey) {
    super(area, toolTipText, urlText);
    ParamChecks.nullNotPermitted(dataset, "dataset");
    this.dataset = dataset;
    this.rowKey = rowKey;
    this.columnKey = columnKey;

    // populate the deprecated fields
    this.series = dataset.getRowIndex(rowKey);
    this.category = columnKey;
    this.categoryIndex = dataset.getColumnIndex(columnKey);
}
 
Example #16
Source File: CombinedRangeCategoryPlot.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes a subplot from the combined chart.
 *
 * @param subplot  the subplot (<code>null</code> not permitted).
 */
public void remove(CategoryPlot subplot) {
    ParamChecks.nullNotPermitted(subplot, "subplot");
    int position = -1;
    int size = this.subplots.size();
    int i = 0;
    while (position == -1 && i < size) {
        if (this.subplots.get(i) == subplot) {
            position = i;
        }
        i++;
    }
    if (position != -1) {
        this.subplots.remove(position);
        subplot.setParent(null);
        subplot.removeChangeListener(this);

        ValueAxis range = getRangeAxis();
        if (range != null) {
            range.configure();
        }

        ValueAxis range2 = getRangeAxis(1);
        if (range2 != null) {
            range2.configure();
        }
        fireChangeEvent();
    }
}
 
Example #17
Source File: TaskSeriesCollection.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes a series from the collection and sends
 * a {@link org.jfree.data.general.DatasetChangeEvent}
 * to all registered listeners.
 *
 * @param series  the series.
 */
public void remove(TaskSeries series) {
    ParamChecks.nullNotPermitted(series, "series");
    if (this.data.contains(series)) {
        series.removeChangeListener(this);
        this.data.remove(series);
        fireDatasetChanged();
    }
}
 
Example #18
Source File: LineBorder.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new border with the specified color.
 *
 * @param paint  the color ({@code null} not permitted).
 * @param stroke  the border stroke ({@code null} not permitted).
 * @param insets  the insets ({@code null} not permitted).
 */
public LineBorder(Paint paint, Stroke stroke, RectangleInsets insets) {
    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    ParamChecks.nullNotPermitted(insets, "insets");
    this.paint = paint;
    this.stroke = stroke;
    this.insets = insets;
}
 
Example #19
Source File: Marker.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new marker.
 *
 * @param paint  the paint ({@code null} not permitted).
 * @param stroke  the stroke ({@code null} not permitted).
 * @param outlinePaint  the outline paint ({@code null} permitted).
 * @param outlineStroke  the outline stroke ({@code null} permitted).
 * @param alpha  the alpha transparency (must be in the range 0.0f to
 *     1.0f).
 *
 * @throws IllegalArgumentException if {@code paint} or
 *     {@code stroke} is {@code null}, or {@code alpha} is
 *     not in the specified range.
 */
protected Marker(Paint paint, Stroke stroke, Paint outlinePaint, 
        Stroke outlineStroke, float alpha) {

    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    if (alpha < 0.0f || alpha > 1.0f) {
        throw new IllegalArgumentException(
                "The 'alpha' value must be in the range 0.0f to 1.0f");
    }

    this.paint = paint;
    this.stroke = stroke;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.alpha = alpha;

    this.labelFont = new Font("SansSerif", Font.PLAIN, 9);
    this.labelPaint = Color.black;
    this.labelBackgroundColor = new Color(100, 100, 100, 100);
    this.labelAnchor = RectangleAnchor.TOP_LEFT;
    this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0);
    this.labelOffsetType = LengthAdjustmentType.CONTRACT;
    this.labelTextAnchor = TextAnchor.CENTER;

    this.listenerList = new EventListenerList();
}
 
Example #20
Source File: MeterInterval.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new interval.
 *
 * @param label  the label (<code>null</code> not permitted).
 * @param range  the range (<code>null</code> not permitted).
 * @param outlinePaint  the outline paint (<code>null</code> permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> permitted).
 * @param backgroundPaint  the background paint (<code>null</code>
 *                         permitted).
 */
public MeterInterval(String label, Range range, Paint outlinePaint,
                     Stroke outlineStroke, Paint backgroundPaint) {
    ParamChecks.nullNotPermitted(label, "label");
    ParamChecks.nullNotPermitted(range, "range");
    this.label = label;
    this.range = range;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.backgroundPaint = backgroundPaint;
}
 
Example #21
Source File: XYTitleAnnotation.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new annotation to be displayed at the specified (x, y)
 * location.
 *
 * @param x  the x-coordinate (in data space).
 * @param y  the y-coordinate (in data space).
 * @param title  the title (<code>null</code> not permitted).
 * @param anchor  the title anchor (<code>null</code> not permitted).
 */
public XYTitleAnnotation(double x, double y, Title title,
        RectangleAnchor anchor) {
    super();
    ParamChecks.nullNotPermitted(title, "title");
    ParamChecks.nullNotPermitted(anchor, "anchor");
    this.coordinateType = XYCoordinateType.RELATIVE;
    this.x = x;
    this.y = y;
    this.maxWidth = 0.0;
    this.maxHeight = 0.0;
    this.title = title;
    this.anchor = anchor;
}
 
Example #22
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a bubble chart with default settings.  The chart is composed of
 * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
 * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
 * to draw the data items.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel,
        String yAxisLabel, XYZDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(
            XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #23
Source File: RectangleConstraint.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new constraint.
 *
 * @param w  the fixed or maximum width.
 * @param widthRange  the width range.
 * @param widthConstraintType  the width type.
 * @param h  the fixed or maximum height.
 * @param heightRange  the height range.
 * @param heightConstraintType  the height type.
 */
public RectangleConstraint(double w, Range widthRange,
                           LengthConstraintType widthConstraintType,
                           double h, Range heightRange,
                           LengthConstraintType heightConstraintType) {
    ParamChecks.nullNotPermitted(widthConstraintType, "widthConstraintType");
    ParamChecks.nullNotPermitted(heightConstraintType, "heightConstraintType");
    this.width = w;
    this.widthRange = widthRange;
    this.widthConstraintType = widthConstraintType;
    this.height = h;
    this.heightRange = heightRange;
    this.heightConstraintType = heightConstraintType;
}
 
Example #24
Source File: MeterInterval.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new interval.
 *
 * @param label  the label (<code>null</code> not permitted).
 * @param range  the range (<code>null</code> not permitted).
 * @param outlinePaint  the outline paint (<code>null</code> permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> permitted).
 * @param backgroundPaint  the background paint (<code>null</code>
 *                         permitted).
 */
public MeterInterval(String label, Range range, Paint outlinePaint,
                     Stroke outlineStroke, Paint backgroundPaint) {
    ParamChecks.nullNotPermitted(label, "label");
    ParamChecks.nullNotPermitted(range, "range");
    this.label = label;
    this.range = range;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.backgroundPaint = backgroundPaint;
}
 
Example #25
Source File: ClusteredXYBarRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Iterates over the items in an {@link IntervalXYDataset} to find
 * the range of x-values including the interval OFFSET so that it centers
 * the interval around the start value.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 *
 * @return The range (possibly <code>null</code>).
 */
protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;
    int seriesCount = dataset.getSeriesCount();
    double lvalue;
    double uvalue;
    for (int series = 0; series < seriesCount; series++) {
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            lvalue = dataset.getStartXValue(series, item);
            uvalue = dataset.getEndXValue(series, item);
            double offset = (uvalue - lvalue) / 2.0;
            lvalue = lvalue - offset;
            uvalue = uvalue - offset;
            minimum = Math.min(minimum, lvalue);
            maximum = Math.max(maximum, uvalue);
        }
    }

    if (minimum > maximum) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example #26
Source File: XYDifferenceRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new renderer.
 *
 * @param positivePaint  the highlight color for positive differences
 *                       (<code>null</code> not permitted).
 * @param negativePaint  the highlight color for negative differences
 *                       (<code>null</code> not permitted).
 * @param shapes  draw shapes?
 */
public XYDifferenceRenderer(Paint positivePaint, Paint negativePaint,
                            boolean shapes) {
    ParamChecks.nullNotPermitted(positivePaint, "positivePaint");
    ParamChecks.nullNotPermitted(negativePaint, "negativePaint");
    this.positivePaint = positivePaint;
    this.negativePaint = negativePaint;
    this.shapesVisible = shapes;
    this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0);
    this.roundXCoordinates = false;
}
 
Example #27
Source File: LegendItem.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new legend item.
 *
 * @param label  the label (<code>null</code> not permitted).
 * @param description  the description (not currently used,
 *        <code>null</code> permitted).
 * @param toolTipText  the tool tip text (<code>null</code> permitted).
 * @param urlText  the URL text (<code>null</code> permitted).
 * @param shapeVisible  a flag that controls whether or not the shape is
 *                      displayed.
 * @param shape  the shape (<code>null</code> permitted).
 * @param shapeFilled  a flag that controls whether or not the shape is
 *                     filled.
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 * @param shapeOutlineVisible  a flag that controls whether or not the
 *                             shape is outlined.
 * @param outlinePaint  the outline paint (<code>null</code> not permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> not
 *                       permitted).
 * @param lineVisible  a flag that controls whether or not the line is
 *                     visible.
 * @param line  the line (<code>null</code> not permitted).
 * @param lineStroke  the stroke (<code>null</code> not permitted).
 * @param linePaint  the line paint (<code>null</code> not permitted).
 */
public LegendItem(AttributedString label, String description,
                  String toolTipText, String urlText,
                  boolean shapeVisible, Shape shape,
                  boolean shapeFilled, Paint fillPaint,
                  boolean shapeOutlineVisible, Paint outlinePaint,
                  Stroke outlineStroke,
                  boolean lineVisible, Shape line, Stroke lineStroke,
                  Paint linePaint) {

    ParamChecks.nullNotPermitted(label, "label");
    ParamChecks.nullNotPermitted(fillPaint, "fillPaint");
    ParamChecks.nullNotPermitted(lineStroke, "lineStroke");
    ParamChecks.nullNotPermitted(line, "line");
    ParamChecks.nullNotPermitted(linePaint, "linePaint");
    ParamChecks.nullNotPermitted(outlinePaint, "outlinePaint");
    ParamChecks.nullNotPermitted(outlineStroke, "outlineStroke");
    this.label = characterIteratorToString(label.getIterator());
    this.attributedLabel = label;
    this.description = description;
    this.shapeVisible = shapeVisible;
    this.shape = shape;
    this.shapeFilled = shapeFilled;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    this.shapeOutlineVisible = shapeOutlineVisible;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.lineVisible = lineVisible;
    this.line = line;
    this.lineStroke = lineStroke;
    this.linePaint = linePaint;
    this.toolTipText = toolTipText;
    this.urlText = urlText;
}
 
Example #28
Source File: AbstractCategoryItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a for the specified item.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 *
 * @return The label (possibly <code>null</code>).
 */
protected String generateLabelString(CategoryDataset dataset,
                                     int row, int column) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    String result;
    Object[] items = createItemArray(dataset, row, column);
    result = MessageFormat.format(this.labelFormat, items);
    return result;

}
 
Example #29
Source File: TimeSeries.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the range of y-values that fall within the specified range of
 * x-values (where the x-values are interpreted as milliseconds since the
 * epoch and converted to time periods using the specified timezone).
 * 
 * @param xRange  the subset of x-values to use (<code>null</code> not
 *     permitted).
 * @param xAnchor  the anchor point for the x-values (<code>null</code>
 *     not permitted).
 * @param zone  the time zone (<code>null</code> not permitted).
 * 
 * @return The range of y-values.
 * 
 * @since 1.0.18
 */
public Range findValueRange(Range xRange, TimePeriodAnchor xAnchor, 
        TimeZone zone) {
    ParamChecks.nullNotPermitted(xRange, "xRange");
    ParamChecks.nullNotPermitted(xAnchor, "xAnchor");
    ParamChecks.nullNotPermitted(zone, "zone");
    if (this.data.isEmpty()) {
        return null;
    }
    Calendar calendar = Calendar.getInstance(zone);
    // since the items are ordered, we could be more clever here and avoid
    // iterating over all the data
    double lowY = Double.POSITIVE_INFINITY;
    double highY = Double.NEGATIVE_INFINITY;
    for (int i = 0; i < this.data.size(); i++) {
        TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.get(i);
        long millis = item.getPeriod().getMillisecond(xAnchor, calendar);
        if (xRange.contains(millis)) {
            Number n = item.getValue();
            if (n != null) {
                double v = n.doubleValue();
                lowY = Math.min(lowY, v);
                highY = Math.max(highY, v);
            }
        }
    }
    if (Double.isInfinite(lowY) && Double.isInfinite(highY)) {
        if (lowY < highY) {
            return new Range(lowY, highY);
        } else {
            return new Range(Double.NaN, Double.NaN);
        }
    }
    return new Range(lowY, highY);
}
 
Example #30
Source File: SunPNGEncoderAdapter.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Encodes an image in PNG format and writes it to an OutputStream.
 *
 * @param bufferedImage  The image to be encoded.
 * @param outputStream  The OutputStream to write the encoded image to.
 * @throws IOException if there is an IO problem.
 */
@Override
public void encode(BufferedImage bufferedImage, OutputStream outputStream)
        throws IOException {
    ParamChecks.nullNotPermitted(bufferedImage, "bufferedImage");
    ParamChecks.nullNotPermitted(outputStream, "outputStream");
    ImageIO.write(bufferedImage, ImageFormat.PNG, outputStream);
}