List of usage examples for org.jfree.util ShapeUtilities createDiamond
public static Shape createDiamond(final float s)
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds the legend elements for self * funding and break even./*from ww w .java 2 s . c o m*/ */ private void addLegendElements(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { // self funding legend XYSeries selfFundingLegend = new XYSeries("Self Funding"); int series = dataset.getSeriesCount(); dataset.addSeries(selfFundingLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createUpTriangle(3.5f)); // break even legend XYSeries breakEvenLegend = new XYSeries("Break Even"); series = dataset.getSeriesCount(); dataset.addSeries(breakEvenLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createDiamond(3.5f)); }
From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java
private JFreeChart createChart(String populationName, CategoryDataset categoryDataset, double max, double min) { CategoryAxis categoryaxis = new CategoryAxis(); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); //categoryaxis.setMaximumCategoryLabelWidthRatio(5F); //categoryaxis.setMaximumCategoryLabelLines(141); //categoryaxis.setCategoryMargin(450); LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer(); lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); lineandshaperenderer.setBaseShapesFilled(false); lineandshaperenderer.setBaseShape(ShapeUtilities.createDiamond((float) 3)); lineandshaperenderer.setBaseSeriesVisibleInLegend(false); //lineandshaperenderer.setBaseLinesVisible(false); lineandshaperenderer.setAutoPopulateSeriesShape(false); lineandshaperenderer.setAutoPopulateSeriesPaint(false); //lineandshaperenderer.findRangeBounds(categoryDataset); NumberAxis numberaxis = new NumberAxis("Expression"); numberaxis.setAutoRangeIncludesZero(false); //numberaxis.setRangeWithMargins(min, max); CategoryPlot categoryplot = new CategoryPlot(categoryDataset, categoryaxis, numberaxis, lineandshaperenderer);//from w w w. j a va2 s .co m categoryplot.setDomainGridlinesVisible(false); categoryplot.setOrientation(PlotOrientation.VERTICAL); JFreeChart jfreechart = new JFreeChart(populationName, new Font("SansSerif", 1, 14), categoryplot, true); return jfreechart; }
From source file:fi.smaa.jsmaa.gui.views.CriterionView.java
private JPanel buildValueFunctionChartPanel(ScaleCriterion criterion) { UtilityFunctionDataset dataset = new UtilityFunctionDataset(criterion); JFreeChart chart = ChartFactory.createXYLineChart("", "x", "v(x)", dataset, PlotOrientation.VERTICAL, false, true, true);/* w w w . ja v a 2 s . co m*/ final XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(0, renderer); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(3.0f)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); ValueAxis rAxis = plot.getRangeAxis(); rAxis.setAutoRange(false); rAxis.setRange(new Range(-0.03, 1.03)); ValueAxis dAxis = plot.getDomainAxis(); dAxis.setLowerMargin(0.03); dAxis.setUpperMargin(0.03); ChartPanel chartPanel = new ChartPanel(chart, false, true, true, false, true); chartPanel.addChartMouseListener(new ValueFunctionMouseListener(chartPanel, criterion, parent)); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); chartPanel.setDisplayToolTips(true); chartPanel.setToolTipText("Click to add/remove partial value function points"); chartPanel.setMouseWheelEnabled(false); chartPanel.setMouseZoomable(false); plot.setDomainCrosshairLockedOnData(false); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); FormLayout layout = new FormLayout("left:pref", "p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); builder.add(chartPanel, cc.xy(1, 1)); builder.add(new ValueFunctionPointsPanel(criterion), cc.xy(1, 3)); return builder.getPanel(); }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds a rolling npv line with self * funding and break even, as well as adding legend elements *//*from w w w . ja va 2s . c o m*/ private void addNpvLine(ProjectRoi projectRoi, String caption, Paint paint, XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { // adds the rolling npvseries and sets approperiate render properties XYSeries rollingNpv = new XYSeries(caption); rollingNpv.add(0.5, 0.0); for (int i = 0; i < projectRoi.rollingNpv.length; i++) { rollingNpv.add(i + 1.5, projectRoi.rollingNpv[i]); } int series = dataset.getSeriesCount(); dataset.addSeries(rollingNpv); renderer.setSeriesShapesVisible(series, false); renderer.setSeriesStroke(series, STROKE_LINE); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, true); // break even if (projectRoi.breakevenPeriod > 0) { XYSeries breakEven = new XYSeries("Break Even"); breakEven.add(projectRoi.breakevenRegression - 0.5, 0.0); series = dataset.getSeriesCount(); dataset.addSeries(breakEven); renderer.setSeriesLinesVisible(series, false); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, false); renderer.setSeriesShape(series, ShapeUtilities.createDiamond(3.5f)); } // selfFunding if (projectRoi.selfFundingPeriod > 1) { XYSeries selfFunding = new XYSeries("Self Funding"); double x = projectRoi.selfFundingPeriod - 0.5; double y = projectRoi.rollingNpv[projectRoi.selfFundingPeriod - 2]; selfFunding.add(x, y); series = dataset.getSeriesCount(); dataset.addSeries(selfFunding); renderer.setSeriesLinesVisible(series, false); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, false); renderer.setSeriesShape(series, ShapeUtilities.createUpTriangle(3.5f)); } }
From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java
private XYPlot createPeriodCostPlot(TangoColorFactory tangoColorFactory, CheapTimeSolution solution) { XYSeries series = new XYSeries("Power price"); for (PeriodPowerPrice periodPowerPrice : solution.getPeriodPowerPriceList()) { series.add((double) periodPowerPrice.getPowerPriceMicros() / 1000000.0, periodPowerPrice.getPeriod()); }/* www . j a va 2 s . c o m*/ XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); renderer.setSeriesPaint(0, TangoColorFactory.ORANGE_1); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(2.0F)); NumberAxis domainAxis = new NumberAxis("Power price"); return new XYPlot(seriesCollection, domainAxis, null, renderer); }
From source file:org.optaplanner.examples.cheaptime.swingui.CheapTimePanel.java
private XYPlot createAvailableCapacityPlot(TangoColorFactory tangoColorFactory, CheapTimeSolution solution) { Map<MachineCapacity, List<Integer>> availableMap = new LinkedHashMap<MachineCapacity, List<Integer>>( solution.getMachineCapacityList().size()); for (MachineCapacity machineCapacity : solution.getMachineCapacityList()) { List<Integer> machineAvailableList = new ArrayList<Integer>(solution.getGlobalPeriodRangeTo()); for (int period = 0; period < solution.getGlobalPeriodRangeTo(); period++) { machineAvailableList.add(machineCapacity.getCapacity()); }//w w w .j av a 2 s. c o m availableMap.put(machineCapacity, machineAvailableList); } for (TaskAssignment taskAssignment : solution.getTaskAssignmentList()) { Machine machine = taskAssignment.getMachine(); Integer startPeriod = taskAssignment.getStartPeriod(); if (machine != null && startPeriod != null) { Task task = taskAssignment.getTask(); List<TaskRequirement> taskRequirementList = task.getTaskRequirementList(); for (int i = 0; i < taskRequirementList.size(); i++) { TaskRequirement taskRequirement = taskRequirementList.get(i); MachineCapacity machineCapacity = machine.getMachineCapacityList().get(i); List<Integer> machineAvailableList = availableMap.get(machineCapacity); for (int j = 0; j < task.getDuration(); j++) { int period = j + taskAssignment.getStartPeriod(); int available = machineAvailableList.get(period); machineAvailableList.set(period, available - taskRequirement.getResourceUsage()); } } } } XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); int seriesIndex = 0; for (Machine machine : solution.getMachineList()) { XYSeries machineSeries = new XYSeries(machine.getLabel()); for (MachineCapacity machineCapacity : machine.getMachineCapacityList()) { List<Integer> machineAvailableList = availableMap.get(machineCapacity); for (int period = 0; period < solution.getGlobalPeriodRangeTo(); period++) { int available = machineAvailableList.get(period); machineSeries.add(available, period); } } seriesCollection.addSeries(machineSeries); renderer.setSeriesPaint(seriesIndex, tangoColorFactory.pickColor(machine)); renderer.setSeriesShape(seriesIndex, ShapeUtilities.createDiamond(1.5F)); renderer.setSeriesVisibleInLegend(seriesIndex, false); seriesIndex++; } NumberAxis domainAxis = new NumberAxis("Capacity"); return new XYPlot(seriesCollection, domainAxis, null, renderer); }
From source file:com.vgi.mafscaling.VECalc.java
protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);//from www.j av a 2s . c om chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); chartPanel.setMouseZoomable(false); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; gbl_chartPanel.insets = new Insets(3, 3, 3, 3); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 1; plotPanel.add(chartPanel, gbl_chartPanel); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = 7593430826693873496L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis xAxis = new NumberAxis(xAxisName); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisName); yAxis.setAutoRangeIncludesZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); }
From source file:gg.view.categoriesbalances.GraphCategoriesBalancesTopComponent.java
/** * Displays the categories/sub-categories' balances by period * @param balances Categories' balances//from w w w . jav a2 s. co m */ private void displayData(Map<Long, Map<SearchCriteria, BigDecimal>> balances) { log.info("Categories' balances graph computed and displayed"); // Display hourglass cursor Utilities.changeCursorWaitStatus(true); // Create the dataset (that will contain the categories/sub-categories' balances) DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Create an empty chart JFreeChart chart = ChartFactory.createLineChart("", // chart title "", // x axis label NbBundle.getMessage(GraphCategoriesBalancesTopComponent.class, "GraphAccountsBalancesTopComponent.Amount"), // y axis label dataset, // data displayed in the chart PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // Chart color chart.setBackgroundPaint(jPanelCategoriesBalances.getBackground()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); // Grid lines plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // Set the orientation of the categories on the domain axis (X axis) CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // Add the series on the chart for each category/sub-category displayed in the table for (Long categoryId : balances.keySet()) { Category category = Wallet.getInstance().getCategoriesWithId().get(categoryId); assert (category != null); SortedSet<SearchCriteria> sortedSearchCriteria = new TreeSet<SearchCriteria>( balances.get(categoryId).keySet()); for (SearchCriteria searchCriteria : sortedSearchCriteria) { if ((!searchCriteria.hasCategoriesFilter() && category.isTopCategory() && !category.getSystemProperty()) || searchCriteria.getCategories().contains(category)) { BigDecimal balance = new BigDecimal(0); if (balances.get(categoryId) != null && balances.get(categoryId).get(searchCriteria) != null) { balance = balances.get(categoryId).get(searchCriteria); } dataset.addValue(balance, category.getName(), searchCriteria.getPeriod()); } } } // Series' shapes LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < dataset.getRowCount(); i++) { renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, ShapeUtilities.createDiamond(2F)); } // Set the scale of the chart NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Create the chart panel that contains the chart ChartPanel chartPanel = new ChartPanel(chart); // Display the chart jPanelCategoriesBalances.removeAll(); jPanelCategoriesBalances.add(chartPanel, BorderLayout.CENTER); jPanelCategoriesBalances.updateUI(); // Display normal cursor Utilities.changeCursorWaitStatus(false); }
From source file:gg.view.accountsbalances.GraphAccountsBalancesTopComponent.java
/** * Displays the accounts' balances by period * @param balances Accounts' balances// www . j a va2s . co m */ private void displayData(Map<MoneyContainer, Map<SearchCriteria, BigDecimal>> balances) { log.info("Accounts' balances graph computed and displayed"); // Display hourglass cursor Utilities.changeCursorWaitStatus(true); // Create the dataset (that will contain the accounts' balances) DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Create an empty chart JFreeChart chart = ChartFactory.createLineChart("", // chart title "", // x axis label NbBundle.getMessage(GraphAccountsBalancesTopComponent.class, "AccountsBalancesTopComponent.Amount"), // y axis label dataset, // data displayed in the chart PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // Chart color chart.setBackgroundPaint(jPanelAccountsBalances.getBackground()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); // Grid lines plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // Set the orientation of the categories on the domain axis (X axis) CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // Add the series on the chart for each account displayed in the table for (MoneyContainer moneyContainer : balances.keySet()) { if (moneyContainer instanceof Account) { Account account = (Account) moneyContainer; SortedSet<SearchCriteria> sortedSearchCriteria = new TreeSet<SearchCriteria>( balances.get(account).keySet()); for (SearchCriteria searchCriteria : sortedSearchCriteria) { if (!searchCriteria.hasAccountsFilter() || searchCriteria.getAccounts().contains(account)) { dataset.addValue(balances.get(moneyContainer).get(searchCriteria), account.toString(), searchCriteria.getPeriod()); } } } } // Series' shapes LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < dataset.getRowCount(); i++) { renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, ShapeUtilities.createDiamond(2F)); } // Set the scale of the chart NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Create the chart panel that contains the chart ChartPanel chartPanel = new ChartPanel(chart); // Display the chart jPanelAccountsBalances.removeAll(); jPanelAccountsBalances.add(chartPanel, BorderLayout.CENTER); jPanelAccountsBalances.updateUI(); // Display normal cursor Utilities.changeCursorWaitStatus(false); }
From source file:gg.view.movementsbalances.GraphMovementsBalancesTopComponent.java
/** * Displays the accounts' movements balances by period * @param searchFilters Search filter objects (one per period) for which the movements balances are wanted */// ww w . jav a2 s .c o m private void displayData(Map<MoneyContainer, Map<SearchCriteria, BigDecimal>> balances) { log.info("Movements' balances graph computed and displayed"); // Display hourglass cursor Utilities.changeCursorWaitStatus(true); // Create the dataset (that will contain the movements' balances) DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Create an empty chart JFreeChart chart = ChartFactory.createLineChart("", // chart title "", // x axis label NbBundle.getMessage(GraphMovementsBalancesTopComponent.class, "GraphMovementsBalancesTopComponent.Amount"), // y axis label dataset, // data displayed in the chart PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // Chart color chart.setBackgroundPaint(jPanelMovementsBalances.getBackground()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); // Grid lines plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // Set the orientation of the categories on the domain axis (X axis) CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // Add the series on the chart for (MoneyContainer moneyContainer : balances.keySet()) { if (moneyContainer instanceof Account) { SortedSet<SearchCriteria> sortedSearchFilters = new TreeSet<SearchCriteria>( balances.get(moneyContainer).keySet()); for (SearchCriteria searchCriteria : sortedSearchFilters) { BigDecimal accountBalance = balances.get(moneyContainer).get(searchCriteria); accountBalance = accountBalance.setScale(2, RoundingMode.HALF_EVEN); dataset.addValue(accountBalance, moneyContainer.toString(), searchCriteria.getPeriod()); } } } // Series' shapes LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < dataset.getRowCount(); i++) { renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, ShapeUtilities.createDiamond(2F)); } // Set the scale of the chart NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Create the chart panel that contains the chart ChartPanel chartPanel = new ChartPanel(chart); // Display the chart jPanelMovementsBalances.removeAll(); jPanelMovementsBalances.add(chartPanel, BorderLayout.CENTER); jPanelMovementsBalances.updateUI(); // Display normal cursor Utilities.changeCursorWaitStatus(false); }