/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.SwingUtilities; import ilog.views.chart.IlvChart; import ilog.views.chart.IlvColor; import ilog.views.chart.IlvDisplayPoint; import ilog.views.chart.IlvStyle; import ilog.views.chart.data.IlvDataSet; import ilog.views.chart.data.IlvDefaultDataSet; import ilog.views.chart.graphic.IlvDataRenderingHint; import ilog.views.chart.graphic.IlvMarker; import ilog.views.chart.graphic.IlvMarkerFactory; import ilog.views.chart.graphic.IlvMarkerHint; import ilog.views.chart.renderer.IlvSinglePolylineRenderer; import ilog.views.util.IlvProductUtil; public class CustomRenderingHint extends JFrame { static final double THRESHOLD = 70.; static class MyHint implements IlvDataRenderingHint, IlvMarkerHint { Override public IlvStyle getStyle(IlvDisplayPoint dp, IlvStyle defaultStyle) { if (dp.getYData() > THRESHOLD) defaultStyle = defaultStyle.setFillPaint(IlvColor.coral); return defaultStyle; } Override public IlvMarker getMarker(IlvDisplayPoint dp, IlvMarker defaultMarker) { if (dp.getYData() > THRESHOLD) return IlvMarkerFactory.getCircleMarker(); return null; } } public CustomRenderingHint() { super("Highlighting Particular Data Points"); setDefaultCloseOperation(EXIT_ON_CLOSE); IlvChart chart = new IlvChart(); chart.setAntiAliasing(true); final double[] values = { 45, 32, 65, 69, 77, 73, 83, 89, 70, 63, 61, 58, 43, 25, 33, 47, 58, 63, 73, 75, 80, 69, 45 }; IlvDataSet ds = new IlvDefaultDataSet("Data Set", values); IlvSinglePolylineRenderer r = new IlvSinglePolylineRenderer(); r.setMarkerSize(5); r.setRenderingHint(ds, new MyHint()); chart.addRenderer(r, ds); chart.getYAxis(0).setDataMin(0); getContentPane().add(chart, BorderLayout.CENTER); setSize(400, 300); } public static void main(String[] args) { // This sample uses JViews Charts features. When deploying an // application that includes this code, you need to be in possession // of a Perforce JViews Charts Deployment license. IlvProductUtil.DeploymentLicenseRequired(IlvProductUtil.JViews_Charts_Deployment); SwingUtilities.invokeLater(new Runnable() { Override public void run() { CustomRenderingHint frame = new CustomRenderingHint(); frame.setVisible(true); } }); } }