protected CategoryAxis configureDomainAxis(CategoryPlot plot) { final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); domainAxis.setLabelFont(CHART_FONT); domainAxis.setTickLabelFont(CHART_FONT); return domainAxis; }
plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0);
plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0);
/** * Sets a domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param axis the axis ({@code null} permitted). * * @see #getDomainAxis(int) */ public void setDomainAxis(int index, CategoryAxis axis) { setDomainAxis(index, axis, true); }
/** * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis (<code>null</code> permitted). * * @see #getDomainAxis() */ public void setDomainAxis(CategoryAxis axis) { setDomainAxis(0, axis); }
/** * Sets a domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param axis the axis (<code>null</code> permitted). * * @see #getDomainAxis(int) */ public void setDomainAxis(int index, CategoryAxis axis) { setDomainAxis(index, axis, true); }
/** * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis ({@code null} permitted). * * @see #getDomainAxis() */ public void setDomainAxis(CategoryAxis axis) { setDomainAxis(0, axis); }
/** * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (<code>null</code> not permitted). * * @see #setRangeAxes(ValueAxis[]) */ public void setDomainAxes(CategoryAxis[] axes) { for (int i = 0; i < axes.length; i++) { setDomainAxis(i, axes[i], false); } fireChangeEvent(); }
/** * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes ({@code null} not permitted). * * @see #setRangeAxes(ValueAxis[]) */ public void setDomainAxes(CategoryAxis[] axes) { for (int i = 0; i < axes.length; i++) { setDomainAxis(i, axes[i], false); } fireChangeEvent(); }
/** * @param barChart TODO * @param subLabelClass */ private static void addSubLabels(JFreeChart barChart, String subLabelClass) { ExtendedCategoryAxis subLabels; CategoryPlot plot = barChart.getCategoryPlot(); try { subLabels = (ExtendedCategoryAxis) Class.forName(subLabelClass).newInstance(); List<?> cats = plot.getCategories(); for(int i=0; i<cats.size(); i++) { subLabels.addSubLabel((Comparable<?>)cats.get(i), cats.get(i).toString()); } plot.setDomainAxis(subLabels); } catch (InstantiationException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (IllegalAccessException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } catch (ClassNotFoundException e) { LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e); } }
JFreeChart chart = makeChart(); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis axis = new CategoryLabelCustomizableCategoryAxis(); axis.setCategoryLabelGenerator(new MyCategoryLabelGenerator()); plot.setDomainAxis(axis);
CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis cx = new CategoryAxis(); cx.setTickLabelsVisible(false); cx.setTickMarksVisible(false); plot.setDomainAxis(cx);
private void configureDomainAxis(CategoryPlot plot, Font font) { CategoryAxis3D categoryAxis = new CategoryAxis3D(); categoryAxis.setTickMarksVisible(true); categoryAxis.setTickLabelFont(font); categoryAxis.setTickLabelPaint(OUTLINE_COLOR); plot.setDomainAxis(categoryAxis); plot.setDomainGridlinesVisible(false); }
private void configureDomainAxis(CategoryPlot plot, Font font) { CategoryAxis categoryAxis = new CategoryAxis(); categoryAxis.setTickMarksVisible(true); categoryAxis.setTickLabelFont(font); categoryAxis.setTickLabelPaint(OUTLINE_COLOR); plot.setDomainAxis(categoryAxis); plot.setDomainGridlinesVisible(false); }
protected CategoryPlot drawChart4FOI(String featureID, String timeString, ObservedValueTuple tuple) { BarRenderer3D barRenderer = new BarRenderer3D(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(new CategoryAxis(featureID)); for (int i = 0; i < observedProperties.length; i++) { plot.setDataset(i, createDataset(i, timeString, tuple)); plot.setRangeAxis(i, new NumberAxis(tuple.getPhenomenonNames()[i].split(":")[tuple.getPhenomenonNames()[i].split(":").length - 1])); plot.setRenderer(i, barRenderer); plot.mapDatasetToRangeAxis(i, i); } return plot; }
protected CategoryAxis configureDomainAxis(CategoryPlot plot) { final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); domainAxis.setLabelFont(CHART_FONT); domainAxis.setTickLabelFont(CHART_FONT); return domainAxis; }
/** * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} * to all registered listeners. * <br><br> * The domain axis for the subplot will be set to {@code null}. You * must ensure that the subplot has a non-null range axis. * * @param subplot the subplot ({@code null} not permitted). * @param weight the weight (must be >= 1). */ public void add(CategoryPlot subplot, int weight) { Args.nullNotPermitted(subplot, "subplot"); if (weight < 1) { throw new IllegalArgumentException("Require weight >= 1."); } subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setDomainAxis(null); subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); CategoryAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); }
//Mock data DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int[] times = new int[]{1,2,3,4,5,6,7,8,9}; for ( int i = 0; i < times.length; i++ ){ dataset.addValue(times[i], "Time", "Hour" + String.valueOf(i+1)); } //create the plot CategoryPlot plot = new CategoryPlot(); //add the first dataset, and render as bar values CategoryItemRenderer renderer = new BarRenderer(); plot.setDataset(0,dataset); plot.setRenderer(0,renderer); //add the second dataset, render as lines CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset); plot.setRenderer(1, renderer2); //set axis plot.setDomainAxis(new CategoryAxis("Time")); plot.setRangeAxis(new NumberAxis("Value"));
/** * Sets properties common to all category graphs of this plug-in. * * @param plot * the chart to set the properties for */ protected void setCategoryPlotProperties(final CategoryPlot plot) { plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setPlotProperties(plot); }
/** * Sets properties common to all category graphs of this plug-in. * * @param plot * the chart to set the properties for */ protected void setCategoryPlotProperties(final CategoryPlot plot) { plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setPlotProperties(plot); }