List of usage examples for org.jfree.chart.axis ValueAxis setInverted
public void setInverted(boolean flag)
From source file:com.itemanalysis.jmetrik.graph.itemmap.ItemMapPanel.java
public void setGraph() { HistogramChartDataset personDataset = null; HistogramChartDataset itemData = null; try {// w w w .j ava 2 s .c o m //get titles String chartTitle = command.getFreeOption("title").getString(); String chartSubtitle = command.getFreeOption("subtitle").getString(); PlotOrientation itemMapOrientation = PlotOrientation.HORIZONTAL; //create common x-axis NumberAxis domainAxis = new NumberAxis(); domainAxis.setLabel("Logits"); //create histogram personDataset = new HistogramChartDataset(); ValueAxis rangeAxis = new NumberAxis("Person Density"); if (itemMapOrientation == PlotOrientation.HORIZONTAL) rangeAxis.setInverted(true); XYBarRenderer renderer = new XYBarRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setURLGenerator(new StandardXYURLGenerator()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); XYPlot personPlot = new XYPlot(personDataset, null, rangeAxis, renderer); personPlot.setOrientation(PlotOrientation.HORIZONTAL); //create scatterplot of item difficulty itemData = new HistogramChartDataset(); NumberAxis itemRangeAxis = new NumberAxis("Item Frequency"); if (itemMapOrientation == PlotOrientation.VERTICAL) { itemRangeAxis.setInverted(true); } XYBarRenderer itemRenderer = new XYBarRenderer(); itemRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); itemRenderer.setURLGenerator(new StandardXYURLGenerator()); itemRenderer.setDrawBarOutline(true); itemRenderer.setShadowVisible(false); XYPlot itemPlot = new XYPlot(itemData, null, itemRangeAxis, itemRenderer); itemPlot.setOrientation(PlotOrientation.HORIZONTAL); //combine the two charts CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis); cplot.add(personPlot, 3); cplot.add(itemPlot, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); cplot.setOrientation(itemMapOrientation); // //next four lines are temp setting for book // //these four lines will create a histogram with white bars so it appears as just the bar outline // renderer.setBarPainter(new StandardXYBarPainter()); // renderer.setSeriesPaint(0, Color.white); // itemRenderer.setBarPainter(new StandardXYBarPainter()); // itemRenderer.setSeriesPaint(0, Color.white); chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); if (chartSubtitle != null && !"".equals(chartSubtitle)) { chart.addSubtitle(new TextTitle(chartSubtitle)); } ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); // //temp setting for book // this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
private void adjustForChartOrientation(final ChartOrientation chartOrientation) { if (chartOrientation == null) { return;/*ww w .jav a 2 s.c o m*/ } final XYPlot plot = getXYPlot(); final ValueAxis hoursAxis = plot.getRangeAxis(); final ValueAxis monthsAxis = plot.getDomainAxis(); switch (chartOrientation) { case STANDARD: hoursAxis.setInverted(true); plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); break; case CONVENTIONAL: break; case VERTICAL: plot.setOrientation(PlotOrientation.HORIZONTAL); monthsAxis.setInverted(true); break; default: break; } }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
@Override public void updateChart(JFreeChart chart) { chart.setShowSubtitle(showColorScale.isSelected()); for (Object object : chart.getSubtitles()) { if (object instanceof PaintScaleLegend) { PaintScale scale = ((PaintScaleLegend) object).getScale(); if (scale instanceof ColorPaintScale) { ((ColorPaintScale) scale).setLogScale(logarithmScale.isSelected()); ((ColorPaintScale) scale).setColorScale((ColorScale) colourScaleCombo.getSelectedItem()); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); if (renderer instanceof XYBlockRenderer) { ((XYBlockRenderer) renderer).setPaintScale(scale); }//w ww. ja v a 2 s . co m } } } ValueAxis axis = chart.getXYPlot().getDomainAxis(); if (flipX.isSelected() != initialFlipX) { axis.setInverted(flipX.isSelected()); } axis = chart.getXYPlot().getRangeAxis(); if (flipY.isSelected() != initialFlipY) { axis.setInverted(flipY.isSelected()); } applyROIChange(); super.updateChart(chart); }
From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationPlot.java
/** * Adds a diagram axis and configures it for the use in this plot. * //from w ww . j av a2 s. co m * @param axis * can be null, if present it is used to define a best suited formatter for the chart axis */ private synchronized void addDiagramAxis(final DiagramAxis diagAxis, final IAxis axis) throws SensorException { if (diagAxis == null) throw new IllegalArgumentException("DiagramAxis is null"); //$NON-NLS-1$ try { final String axisType = axis == null ? null : axis.getType(); final String axisClass = TimeseriesUtils.getAxisClassFor(axisType); if (axisClass == null) { final String msg = String.format( "No Axis-Class defined for type '%s'. Must be defined in timeseries.ini or /KalypsoCore/src/org/kalypso/ogc/sensor/timeseries/resource/config.properties", //$NON-NLS-1$ axisType); throw new SensorException(msg); } final String axisLabel = diagAxis.toFullString(); // Small hack:_ if label is null, we need to instantiate with an string, else the reflection does not work. final String[] arguments = axisLabel == null ? new String[] { "" } : new String[] { axisLabel }; //$NON-NLS-1$ final ValueAxis vAxis = (ValueAxis) ClassUtilities.newInstance(axisClass, ValueAxis.class, ObservationPlot.class.getClassLoader(), arguments); if (axisLabel == null) vAxis.setLabel(null); setTimezone(vAxis); vAxis.setInverted(diagAxis.isInverted()); if (diagAxis.getLowerMargin() != null) vAxis.setLowerMargin(diagAxis.getLowerMargin().doubleValue()); if (diagAxis.getUpperMaring() != null) vAxis.setUpperMargin(diagAxis.getUpperMaring().doubleValue()); final AxisLocation loc = getLocation(diagAxis); if (diagAxis.getDirection().equals(DiagramAxis.DIRECTION_HORIZONTAL)) { final int pos = getAdequateDomainPos(); setDomainAxis(pos, vAxis); setDomainAxisLocation(pos, loc); m_chartAxes2Pos.put(vAxis, new Integer(pos)); } else { final int pos = getAdequateRangePos(); setRangeAxis(pos, vAxis); setRangeAxisLocation(pos, loc); m_chartAxes2Pos.put(vAxis, new Integer(pos)); } m_diag2chartAxis.put(diagAxis, vAxis); } catch (final ClassUtilityException e) { throw new SensorException(e); } }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
@Override public void updateChart(JFreeChart chart) { super.updateChart(chart); if (currentSeriesIndex >= 0) { XYItemRenderer renderer = chart.getXYPlot().getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { renderer.setSeriesPaint(currentSeriesIndex, curveColorPaint.getPaint()); Stroke stroke = curveStrokeSample.getStroke(); if (stroke == null) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(currentSeriesIndex, false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(currentSeriesIndex, true); renderer.setSeriesStroke(currentSeriesIndex, stroke); }/*from ww w. j a v a 2 s. co m*/ ((XYErrorRenderer) renderer).setDrawYError(showError.isSelected()); boolean isMarkerVisible = showMarker.isSelected(); if (!isMarkerVisible) { for (int i = 0; i < chart.getXYPlot().getSeriesCount(); i++) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(i, isMarkerVisible); } } ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(isMarkerVisible); Shape shape = currentShape.getShape(); if (shape == null) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(currentSeriesIndex, false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(currentSeriesIndex, isMarkerVisible); renderer.setSeriesShape(currentSeriesIndex, shape); } ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(currentSeriesIndex, markerFilled.isSelected()); renderer.setSeriesVisible(currentSeriesIndex, curveVisable.isSelected()); //Update logarithm X filed ValueAxis axis = chart.getXYPlot().getDomainAxis(); if (axis instanceof LogarithmizableAxis) { if (logarithmX.isSelected() != initialLogarithmX) { ((LogarithmizableAxis) axis).setLogarithmic(logarithmX.isSelected()); ((LogarithmizableAxis) axis).autoAdjustRange(); } } if (flipX.isSelected() != initialFlipX) { axis.setInverted(flipX.isSelected()); } float newMargin = initialMargin; try { newMargin = Float.valueOf(horizontalMargin.getText()); if (newMargin < 0) { newMargin = 0; } else if (newMargin > 0.10) { newMargin = 0.10f; } } catch (Exception e) { } if (newMargin != initialMargin) { axis.setLowerMargin(newMargin); axis.setUpperMargin(newMargin); } //Update logarithm Y filed axis = chart.getXYPlot().getRangeAxis(); if (axis instanceof LogarithmizableAxis) { if (logarithmY.isSelected() != initialLogarithmY) { ((LogarithmizableAxis) axis).setLogarithmic(logarithmY.isSelected()); ((LogarithmizableAxis) axis).autoAdjustRange(); } } if (flipY.isSelected() != initialFlipY) { axis.setInverted(flipY.isSelected()); } } } applyROIChange(); }