List of usage examples for org.jfree.chart.title TextTitle TextTitle
public TextTitle()
From source file:org.gephi.desktop.context.ContextPieChart.java
public ContextPieChart() { data = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null);//from ww w .ja v a 2s. com chart.setPadding(new RectangleInsets(0, 0, 0, 0)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(null); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.WHITE); plot.setLabelGap(0.5); plot.setCircular(true); plot.setInteriorGap(0); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222)); plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD)); chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false); ((FlowLayout) chartPanel.getLayout()).setHgap(0); ((FlowLayout) chartPanel.getLayout()).setVgap(0); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); }
From source file:org.gephi.desktop.partition.PartitionPie.java
public void setup(Partition partition) { data = new DefaultPieDataset(); for (Part p : partition.getParts()) { data.setValue(p.getDisplayName(), p.getPercentage()); }/*from ww w . j ava 2s . co m*/ final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); //plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.BLACK); //plot.setLabelGap(0.05); plot.setCircular(true); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); for (Part p : partition.getParts()) { plot.setSectionPaint(p.getDisplayName(), p.getColor()); } chartPanel = new ChartPanel(chart, true); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); add(chartPanel, BorderLayout.CENTER); }
From source file:net.sf.mzmine.modules.visualization.histogram.HistogramChart.java
public HistogramChart() { super(null, true); // initialize the chart by default time series chart from factory chart = ChartFactory.createHistogram("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );//from w ww . j a v a 2 s . c om // title chartTitle = chart.getTitle(); chartTitle.setFont(titleFont); chartTitle.setMargin(5, 0, 0, 0); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // legend constructed by ChartFactory LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(true); // set the logarithmic axis NumberAxis axisDomain = new HistogramDomainAxis(); axisDomain.setMinorTickCount(1); axisDomain.setAutoRange(true); NumberAxis axisRange = new NumberAxis(); axisRange.setMinorTickCount(1); axisRange.setAutoRange(true); plot.setDomainAxis(axisDomain); plot.setRangeAxis(axisRange); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setMargin(marginSize); renderer.setShadowVisible(false); plot.setRenderer(renderer); this.setMinimumSize(new Dimension(400, 400)); this.setDismissDelay(Integer.MAX_VALUE); this.setInitialDelay(0); }
From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramPanel.java
public void setGraph() { HistogramChartDataset dataset = null; dataset = new HistogramChartDataset(); chart = HistogramChart.createHistogram(chartTitle, xlabel, //x-axis label ylabel, //y-axis label dataset, chartOrientation, hasGroupingVariable, //legend true, //tooltips false //urls );// www .j a v a2 s. co m if (chartSubtitle != null && !"".equals(chartSubtitle)) { TextTitle subtitle1 = new TextTitle(); chart.addSubtitle(subtitle1); } XYPlot plot = (XYPlot) chart.getPlot(); if (hasGroupingVariable) plot.setForegroundAlpha(0.80f); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); //next two lines are temp setting for book //these two 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); 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); }
From source file:net.sf.mzmine.modules.visualization.twod.TwoDPlot.java
TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset, Range rtRange, Range mzRange) {//w w w .java2s .co m super(null, true); this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; setBackground(Color.white); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // set the X axis (retention time) properties xAxis = new NumberAxis("Retention time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); // set the Y axis (intensity) properties yAxis = new NumberAxis("m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the plot properties plot = new TwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); JMenuItem plotTypeMenuItem = new JMenuItem("Toggle centroid/continuous mode"); plotTypeMenuItem.addActionListener(visualizer); plotTypeMenuItem.setActionCommand("SWITCH_PLOTMODE"); add(plotTypeMenuItem); JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); popupMenu.add(plotTypeMenuItem); }
From source file:net.sf.mzmine.modules.visualization.spectra.SpectraPlot.java
public SpectraPlot(ActionListener masterPlot) { super(null, true); setBackground(Color.white);/*ww w .j a va2 s.co m*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "m/z", // x-axis label "Intensity", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // isotopeFlag, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // legend constructed by ChartFactory LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); setMinimumDrawHeight(0); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(mzFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(intensityFormat); // set focusable state to receive key events setFocusable(true); // register key handlers GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("LEFT"), masterPlot, "PREVIOUS_SCAN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("RIGHT"), masterPlot, "NEXT_SCAN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('+'), this, "ZOOM_IN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('-'), this, "ZOOM_OUT"); // add items to popup menu if (masterPlot instanceof SpectraVisualizerWindow) { JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Toggle centroid/continuous mode", masterPlot, "TOGGLE_PLOT_MODE"); GUIUtils.addMenuItem(popupMenu, "Toggle displaying of data points in continuous mode", masterPlot, "SHOW_DATA_POINTS"); GUIUtils.addMenuItem(popupMenu, "Toggle displaying of peak values", masterPlot, "SHOW_ANNOTATIONS"); GUIUtils.addMenuItem(popupMenu, "Toggle displaying of picked peaks", masterPlot, "SHOW_PICKED_PEAKS"); popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Set axes range", masterPlot, "SETUP_AXES"); GUIUtils.addMenuItem(popupMenu, "Set same range to all windows", masterPlot, "SET_SAME_RANGE"); popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Add isotope pattern", masterPlot, "ADD_ISOTOPE_PATTERN"); } }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartPieGraphSource.java
@SuppressWarnings("unchecked") @Override//from w w w . ja v a2s .c o m public void initialize() throws GraphException { String title = getParam(GraphSource.GRAPH_TITLE, String.class, DEFAULT_TITLE); boolean legend = getParam(GraphSource.GRAPH_LEGEND, Boolean.class, DEFAULT_GRAPH_LEGEND); boolean graphToolTip = getParam(GraphSource.GRAPH_TOOL_TIP, Boolean.class, DEFAULT_GRAPH_TOOL_TIP); boolean graphDisplayLabel = getParam(GraphSource.GRAPH_DISPLAY_LABEL, Boolean.class, false); boolean legendBorder = getParam(GraphSource.LEGEND_BORDER, Boolean.class, DEFAULT_LEGEND_BORDER); boolean graphBorder = getParam(GraphSource.GRAPH_BORDER, Boolean.class, DEFAULT_GRAPH_BORDER); Font titleFont = getParam(GraphSource.GRAPH_FONT, Font.class, DEFAULT_GRAPH_TITLE_FONT); String noDataMessage = getParam(GraphSource.GRAPH_NO_DATA_MESSAGE, String.class, DEFAULT_GRAPH_NO_DATA_MESSAGE); PieGraphData pieGraphData = makeDataSet(); Map<Comparable, Paint> colors = pieGraphData.colors; this.chart = ChartFactory.createPieChart(title, pieGraphData.data, false, graphToolTip, false); Paint backgroundColor = getParam(GraphSource.BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); Paint plotColor = getParam(JFreeChartTimeSeriesGraphSource.PLOT_COLOR, Paint.class, backgroundColor); Paint labelColor = getParam(JFreeChartTimeSeriesGraphSource.GRAPH_LABEL_BACKGROUND_COLOR, Paint.class, DEFAULT_BACKGROUND_COLOR); this.chart.setBackgroundPaint(backgroundColor); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(plotColor); plot.setNoDataMessage(noDataMessage); if (!graphDisplayLabel) { plot.setLabelGenerator(null); } else { plot.setInteriorGap(0.001); plot.setMaximumLabelWidth(.3); // plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setShadowPaint(null); // plot.setOutlineVisible(false); //TODO use title font? Font font = plot.getLabelFont(); plot.setLabelLinkStyle(PieLabelLinkStyle.CUBIC_CURVE); plot.setLabelFont(font.deriveFont(font.getSize2D() * .75f)); plot.setLabelBackgroundPaint(labelColor); plot.setLabelShadowPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelGap(0.001); plot.setLabelLinkMargin(0.0); plot.setLabelLinksVisible(true); // plot.setSimpleLabels(true); // plot.setCircular(true); } if (!graphBorder) { plot.setOutlineVisible(false); } if (title != null && !"".equals(title)) { TextTitle title1 = new TextTitle(); title1.setText(title); title1.setFont(titleFont); title1.setPadding(3, 2, 5, 2); chart.setTitle(title1); } else { chart.setTitle((TextTitle) null); } plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); //Makes a wrapper for the legend to remove the border around it if (legend) { LegendTitle legend1 = new LegendTitle(chart.getPlot()); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); if (legendBorder) { wrapper.setFrame(new BlockBorder(1, 1, 1, 1)); } else { wrapper.setFrame(new BlockBorder(0, 0, 0, 0)); } BlockContainer items = legend1.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend1.setWrapper(wrapper); legend1.setPosition(RectangleEdge.BOTTOM); legend1.setHorizontalAlignment(HorizontalAlignment.CENTER); if (params.get(GraphSource.LEGEND_FONT) instanceof Font) { legend1.setItemFont(((Font) params.get(GraphSource.LEGEND_FONT))); } chart.addSubtitle(legend1); plot.setLegendLabelGenerator(new PieGraphLabelGenerator()); } for (Comparable category : colors.keySet()) { plot.setSectionPaint(category, colors.get(category)); } plot.setToolTipGenerator(new PieGraphToolTipGenerator(pieGraphData)); plot.setURLGenerator(new PieGraphURLGenerator(pieGraphData)); initialized = true; }
From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java
IDAPlot(final ActionListener listener, RawDataFile rawDataFile, IDAVisualizerWindow visualizer, IDADataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );//from w w w.jav a 2 s .com chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new IDAPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java
MsMsPlot(final ActionListener listener, RawDataFile rawDataFile, MsMsVisualizerWindow visualizer, MsMsDataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs );/* w w w .java2 s .c om*/ chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new MsMsPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java
public TICPlot(final ActionListener listener) { super(null, true); // Initialize. visualizer = listener;/* w w w . ja v a 2 s . c om*/ labelsVisible = 1; havePeakLabels = false; numOfDataSets = 0; numOfPeaks = 0; showSpectrumRequest = false; // Set cursor. setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // Y-axis label. final String yAxisLabel; if (listener instanceof TICVisualizerWindow) { yAxisLabel = ((TICVisualizerWindow) listener).getPlotType() == PlotType.BASEPEAK ? "Base peak intensity" : "Total ion intensity"; } else { yAxisLabel = "Base peak intensity"; } // Initialize the chart by default time series chart from factory. final JFreeChart chart = ChartFactory.createXYLineChart("", // title "Retention time", // x-axis label yAxisLabel, // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); setChart(chart); // Title. chartTitle = chart.getTitle(); chartTitle.setFont(TITLE_FONT); chartTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); // Subtitle. chartSubTitle = new TextTitle(); chartSubTitle.setFont(SUBTITLE_FONT); chartSubTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); chart.addSubtitle(chartSubTitle); // Disable maximum size (we don't want scaling). setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // Legend constructed by ChartFactory. final LegendTitle legend = chart.getLegend(); legend.setItemFont(LEGEND_FONT); legend.setFrame(BlockBorder.NONE); // Set the plot properties. plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(AXIS_OFFSET); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // Set grid properties. plot.setDomainGridlinePaint(GRID_COLOR); plot.setRangeGridlinePaint(GRID_COLOR); // Set cross-hair (selection) properties. if (listener instanceof TICVisualizerWindow) { plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(CROSS_HAIR_COLOR); plot.setRangeCrosshairPaint(CROSS_HAIR_COLOR); plot.setDomainCrosshairStroke(CROSS_HAIR_STROKE); plot.setRangeCrosshairStroke(CROSS_HAIR_STROKE); } // Set the x-axis (retention time) properties. final NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat()); xAxis.setUpperMargin(AXIS_MARGINS); xAxis.setLowerMargin(AXIS_MARGINS); // Set the y-axis (intensity) properties. final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat()); // Set default renderer properties. defaultRenderer = new TICPlotRenderer(); defaultRenderer.setBaseShapesFilled(true); defaultRenderer.setDrawOutlines(false); defaultRenderer.setUseFillPaint(true); defaultRenderer.setBaseItemLabelPaint(LABEL_COLOR); // Set label generator final XYItemLabelGenerator labelGenerator = new TICItemLabelGenerator(this); defaultRenderer.setBaseItemLabelGenerator(labelGenerator); defaultRenderer.setBaseItemLabelsVisible(true); // Set toolTipGenerator final XYToolTipGenerator toolTipGenerator = new TICToolTipGenerator(); defaultRenderer.setBaseToolTipGenerator(toolTipGenerator); // Set focus state to receive key events. setFocusable(true); // Register key handlers. GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("LEFT"), listener, "MOVE_CURSOR_LEFT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("RIGHT"), listener, "MOVE_CURSOR_RIGHT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), listener, "SHOW_SPECTRUM"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('+'), this, "ZOOM_IN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('-'), this, "ZOOM_OUT"); // Add items to popup menu. final JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); if (listener instanceof TICVisualizerWindow) { popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); popupMenu.add(new AddFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new RemoveFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); } GUIUtils.addMenuItem(popupMenu, "Toggle showing peak values", this, "SHOW_ANNOTATIONS"); GUIUtils.addMenuItem(popupMenu, "Toggle showing data points", this, "SHOW_DATA_POINTS"); if (listener instanceof TICVisualizerWindow) { popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Show spectrum of selected scan", listener, "SHOW_SPECTRUM"); } popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Set axes range", this, "SETUP_AXES"); if (listener instanceof TICVisualizerWindow) { GUIUtils.addMenuItem(popupMenu, "Set same range to all windows", this, "SET_SAME_RANGE"); } }