List of usage examples for org.jfree.chart.title LegendTitle isVisible
public boolean isVisible()
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartDesignEvaluator.java
/** * /*from w ww .jav a 2 s. co m*/ */ public static JRRenderable evaluateRenderer(ReportConverter reportConverter, JRComponentElement element) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = chartComponent.getPlot(); SpiderWebPlot spiderWebPlot = new SpiderWebPlot(getSampleDataset()); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } spiderWebPlot.setMaxValue(MAX_VALUE); if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator()); String titleText = JRExpressionUtil.getExpressionText(chartSettings.getTitleExpression()); Font titleFont = chartSettings.getTitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); if (chartSettings.getBackcolor() != null) { jfreechart.setBackgroundPaint(chartSettings.getBackcolor()); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = JRExpressionUtil.getExpressionText(chartSettings.getSubtitleExpression()); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(JRFontUtil.getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); String renderType = chartSettings.getRenderType(); if (renderType == null) { renderType = JRProperties.getProperty(reportConverter.getReport(), JRChart.PROPERTY_CHART_RENDER_TYPE); } return ChartUtil.getChartRendererFactory(renderType).getRenderer(jfreechart, null, rectangle); }
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartRendererEvaluator.java
/** * /*from w w w. j a va2 s. co m*/ */ public static Renderable evaluateRenderable(JasperReportsContext jasperReportsContext, JRComponentElement element, SpiderChartSharedBean spiderchartBean, ChartCustomizer chartCustomizer, String defaultRenderType, String datasetType) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = (SpiderPlot) chartComponent.getPlot(); DefaultCategoryDataset dataset = null; StandardCategoryItemLabelGenerator labelGenerator = null; if (FILL_DATASET.equals(datasetType)) { dataset = ((FillSpiderDataset) spiderchartBean.getDataset()).getCustomDataset(); labelGenerator = ((FillSpiderDataset) spiderchartBean.getDataset()).getLabelGenerator(); } else { dataset = getSampleDataset(); labelGenerator = new StandardCategoryItemLabelGenerator(); } SpiderWebPlot spiderWebPlot = new SpiderWebPlot(dataset); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(FontUtil.getInstance(jasperReportsContext).getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } if (spiderchartBean.getMaxValue() != null) { spiderWebPlot.setMaxValue(spiderchartBean.getMaxValue()); } if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(labelGenerator); Font titleFont = chartSettings.getTitleFont() != null ? FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; String titleText = spiderchartBean.getTitleText(); JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); Color backcolor = chartSettings.getBackcolor() != null ? chartSettings.getBackcolor() : element.getBackcolor(); if (backcolor != null) { jfreechart.setBackgroundPaint(backcolor); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = spiderchartBean.getSubtitleText(); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? FontUtil.getInstance(jasperReportsContext).getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } String renderType = chartSettings.getRenderType() == null ? defaultRenderType : chartSettings.getRenderType(); Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); if (chartCustomizer != null) { chartCustomizer.customize(jfreechart, chartComponent); } return ChartUtil.getInstance(jasperReportsContext).getChartRenderableFactory(renderType) .getRenderable(jasperReportsContext, jfreechart, spiderchartBean.getHyperlinkProvider(), rectangle); }
From source file:org.gumtree.vis.core.internal.SWTChartComposite.java
@Override protected Menu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { Menu result = super.createPopupMenu(properties, save, print, zoom); LegendTitle legend = getChart().getLegend(); if (legend != null) { boolean isVisable = legend.isVisible(); RectangleEdge location = legend.getPosition(); new MenuItem(result, SWT.SEPARATOR); Menu legendMenu = new Menu(result); MenuItem legendMenuGroup = new MenuItem(result, SWT.CASCADE); legendMenuGroup.setMenu(legendMenu); legendMenuGroup.setText("Legend"); legendButtomMenuItem = new MenuItem(legendMenu, SWT.RADIO); legendButtomMenuItem.setText("Bottom"); legendButtomMenuItem.setData(LEGEND_BOTTOM_COMMAND); legendButtomMenuItem.addSelectionListener(this); if (isVisable && location.equals(RectangleEdge.BOTTOM)) { legendButtomMenuItem.setSelection(true); }//from ww w . java 2 s . co m legendRightMenuItem = new MenuItem(legendMenu, SWT.RADIO); legendRightMenuItem.setText("Right"); legendRightMenuItem.setData(LEGEND_RIGHT_COMMAND); legendRightMenuItem.addSelectionListener(this); if (isVisable && location.equals(RectangleEdge.RIGHT)) { legendRightMenuItem.setSelection(true); } // new MenuItem(legendMenu, SWT.SEPARATOR); legendNoneMenuItem = new MenuItem(legendMenu, SWT.RADIO); legendNoneMenuItem.setText("None"); legendNoneMenuItem.setData(LEGEND_NONE_COMMAND); legendNoneMenuItem.addSelectionListener(this); if (!isVisible()) { legendNoneMenuItem.setSelection(true); } } new MenuItem(result, SWT.SEPARATOR); copyMenuItem = new MenuItem(result, SWT.NONE); copyMenuItem.setText("Copy"); copyMenuItem.setData(COPY_COMMAND); copyMenuItem.addSelectionListener(this); return result; }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java
@Override public void actionPerformed(final ActionEvent event) { super.actionPerformed(event); final String command = event.getActionCommand(); if ("SHOW_DATA_POINTS".equals(command)) { switchDataPointsVisible();//from w ww. j av a2 s .c o m } if ("SHOW_ANNOTATIONS".equals(command)) { switchItemLabelsVisible(); } if ("SETUP_AXES".equals(command)) { new AxesSetupDialog(getXYPlot()).setVisible(true); } if ("ZOOM_IN".equals(command)) { getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR); } if ("ZOOM_OUT".equals(command)) { getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR); } if ("SET_SAME_RANGE".equals(command)) { // Get current axes range. final NumberAxis xAxis = (NumberAxis) getXYPlot().getDomainAxis(); final NumberAxis yAxis = (NumberAxis) getXYPlot().getRangeAxis(); final double xMin = xAxis.getRange().getLowerBound(); final double xMax = xAxis.getRange().getUpperBound(); final double xTick = xAxis.getTickUnit().getSize(); final double yMin = yAxis.getRange().getLowerBound(); final double yMax = yAxis.getRange().getUpperBound(); final double yTick = yAxis.getTickUnit().getSize(); // Set the range of these frames for (final Window frame : JFrame.getWindows()) { if (frame instanceof TICVisualizerWindow) { final TICVisualizerWindow ticFrame = (TICVisualizerWindow) frame; ticFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick); } } } if ("SHOW_SPECTRUM".equals(command)) { visualizer.actionPerformed(event); } if ("SHOW_LEGEND".equals(command)) { // Toggle legend visibility. final LegendTitle legend = getChart().getLegend(); legend.setVisible(!legend.isVisible()); } }
From source file:net.sf.jasperreports.components.spiderchart.FillSpiderChart.java
protected JFreeChart evaluateChart(byte evaluation) throws JRException { maxValue = (Double) fillContext.evaluate(getPlot().getMaxValueExpression(), evaluation); titleText = (String) fillContext.evaluate(getChartSettings().getTitleExpression(), evaluation); subtitleText = (String) fillContext.evaluate(getChartSettings().getSubtitleExpression(), evaluation); anchorName = (String) fillContext.evaluate(getChartSettings().getAnchorNameExpression(), evaluation); hyperlinkReference = (String) fillContext.evaluate(getChartSettings().getHyperlinkReferenceExpression(), evaluation);/*from w w w . j a va 2 s . co m*/ hyperlinkAnchor = (String) fillContext.evaluate(getChartSettings().getHyperlinkAnchorExpression(), evaluation); hyperlinkPage = (Integer) fillContext.evaluate(getChartSettings().getHyperlinkPageExpression(), evaluation); hyperlinkTooltip = (String) fillContext.evaluate(getChartSettings().getHyperlinkTooltipExpression(), evaluation); hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters(getChartSettings(), expressionEvaluator, evaluation); dataset.evaluateDatasetRun(evaluation); dataset.finishDataset(); chartHyperlinkProvider = new CategoryChartHyperlinkProvider(dataset.getItemHyperlinks()); bookmarkLevel = getChartSettings().getBookmarkLevel(); SpiderWebPlot spiderWebPlot = new SpiderWebPlot((DefaultCategoryDataset) dataset.getCustomDataset()); if (getPlot().getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(getPlot().getAxisLineColor()); } if (getPlot().getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(getPlot().getAxisLineWidth())); } if (getPlot().getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(getPlot().getBackcolor()); } if (getPlot().getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(getPlot().getBackgroundAlpha()); } if (getPlot().getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(getPlot().getForegroundAlpha()); } if (getPlot().getHeadPercent() != null) { spiderWebPlot.setHeadPercent(getPlot().getHeadPercent()); } if (getPlot().getInteriorGap() != null) { spiderWebPlot.setInteriorGap(getPlot().getInteriorGap()); } if (getPlot().getLabelColor() != null) { spiderWebPlot.setLabelPaint(getPlot().getLabelColor()); } if (getPlot().getLabelFont() != null) { spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(getPlot().getLabelFont(), Locale.getDefault())); } if (getPlot().getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(getPlot().getLabelGap()); } if (maxValue != null) { spiderWebPlot.setMaxValue(maxValue); } if (getPlot().getRotation() != null) { spiderWebPlot.setDirection(getPlot().getRotation().getRotation()); } if (getPlot().getStartAngle() != null) { spiderWebPlot.setStartAngle(getPlot().getStartAngle()); } if (getPlot().getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(getPlot().getTableOrder().getOrder()); } if (getPlot().getWebFilled() != null) { spiderWebPlot.setWebFilled(getPlot().getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator()); Font titleFont = getChartSettings().getTitleFont() != null ? JRFontUtil.getAwtFont(getChartSettings().getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); if (chartSettings.getBackcolor() != null) { jfreechart.setBackgroundPaint(chartSettings.getBackcolor()); } RectangleEdge titleEdge = getEdge(getChartSettings().getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (getChartSettings().getTitleColor() != null) { title.setPaint(getChartSettings().getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (getChartSettings().getSubtitleColor() != null) { subtitle.setPaint(getChartSettings().getSubtitleColor()); } if (getChartSettings().getSubtitleColor() != null) { Font subtitleFont = getChartSettings().getSubtitleFont() != null ? JRFontUtil.getAwtFont(getChartSettings().getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (getChartSettings().getLegendColor() != null) { legend.setItemPaint(getChartSettings().getLegendColor()); } if (getChartSettings().getLegendBackgroundColor() != null) { legend.setBackgroundPaint(getChartSettings().getLegendBackgroundColor()); } if (getChartSettings().getLegendFont() != null) { legend.setItemFont( JRFontUtil.getAwtFont(getChartSettings().getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(getChartSettings().getLegendPosition(), RectangleEdge.BOTTOM)); } } return jfreechart; }
From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java
/** * paint this chart as legend// w w w . ja v a2 s . co m * * @param graphics * the graphics * @param bounds * the bounds */ private final void __paintAsLegend(final Graphics2D graphics, final Rectangle bounds) { final LegendTitle legend; final _JFCXYItemRenderer render; final XYItemRenderer old; Rectangle2D r; double w, h; legend = this.m_chart.getLegend(); if ((legend == null) || (!(legend.isVisible()))) { this.m_chart.draw(graphics, bounds); return; } legend.setVisible(false); old = this.m_plot.getRenderer(); try { render = new _JFCXYItemRenderer(old); this.m_plot.setRenderer(render); this.m_plot.setRenderer(0, render); this.paint(graphics, bounds); legend.setVisible(true); legend.setBackgroundPaint(this.m_plot.getBackgroundPaint()); w = (render.m_maxX - render.m_minX); h = (render.m_maxY - render.m_minY); r = new Rectangle2D.Double(// render.m_minX + (0.05d * w), // render.m_minY + (0.05d * h), // w * 0.9d, // h * 0.9d); _JFCLineChart2D.__paintLegend(legend, graphics, r); } finally { this.m_plot.setRenderer(old); } }
From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java
/** {@inheritDoc} */ @Override// w ww.jav a 2 s. c o m protected final void draw(final Graphics2D graph, final Rectangle bounds) { final LegendTitle t; final RectangleInsets ri; if (this.getLegendType() == ELegendType.ONLY_LEGEND) { this.__paintAsLegend(graph, bounds); return; } t = this.m_chart.getLegend(); if ((t != null) && (t.isVisible())) { if (bounds.height < bounds.width) { t.setPosition(RectangleEdge.RIGHT); } else { t.setPosition(RectangleEdge.BOTTOM); } } ri = this.m_plot.getInsets(); this.m_plot.setInsets(new RectangleInsets(ri.getTop(), 0d, 0d, // ri.getRight())); this.m_chart.draw(graph, bounds); }
From source file:org.gumtree.vis.awt.time.TimePlotPanel.java
@Override protected void displayPopupMenu(int x, int y) { LegendTitle legend = getChart().getLegend(); if (legend != null) { boolean isVisable = legend.isVisible(); RectangleEdge location = legend.getPosition(); if (isVisable) { if (location.equals(RectangleEdge.BOTTOM)) { legendBottom.setSelected(true); legendNone.setSelected(false); legendRight.setSelected(false); } else if (isVisable && location.equals(RectangleEdge.RIGHT)) { legendRight.setSelected(true); legendNone.setSelected(false); legendBottom.setSelected(false); }// www. j ava 2s . com } else { legendNone.setSelected(true); legendRight.setSelected(false); legendBottom.setSelected(false); } } curveManagementMenu.removeAll(); curveResetMenu.removeAll(); if (getXYPlot().getDatasetCount() > 0) { curveManagementMenu.setEnabled(true); curveResetMenu.setEnabled(true); JMenuItem focusNoneCurveItem = new JRadioButtonMenuItem(); focusNoneCurveItem.setText("None"); focusNoneCurveItem.setActionCommand(UNFOCUS_CURVE_COMMAND); focusNoneCurveItem.addActionListener(this); curveManagementMenu.add(focusNoneCurveItem); JMenuItem resetAllCurveItem = new JMenuItem(); resetAllCurveItem.setText("RESET ALL"); resetAllCurveItem.setActionCommand(RESET_ALL_CURVE_COMMAND); resetAllCurveItem.addActionListener(this); curveResetMenu.add(resetAllCurveItem); boolean isCurveFocused = false; for (int j = 0; j < getXYPlot().getDatasetCount(); j++) { XYDataset dataset = getChart().getXYPlot().getDataset(j); if (dataset != null) { for (int i = 0; i < dataset.getSeriesCount(); i++) { String seriesKey = (String) dataset.getSeriesKey(i); JMenuItem focusOnCurveItem = new JRadioButtonMenuItem(); focusOnCurveItem.setText(seriesKey); focusOnCurveItem.setActionCommand(FOCUS_ON_COMMAND + "-" + seriesKey); focusOnCurveItem.addActionListener(this); curveManagementMenu.add(focusOnCurveItem); if (dataset == selectedDataset && i == selectedSeriesIndex) { focusOnCurveItem.setSelected(true); isCurveFocused = true; } JMenuItem resetCurveItem = new JMenuItem(); resetCurveItem.setText("Reset " + seriesKey); resetCurveItem.setActionCommand(RESET_CURVE_COMMAND + "-" + seriesKey); resetCurveItem.addActionListener(this); curveResetMenu.add(resetCurveItem); } } } if (!isCurveFocused) { focusNoneCurveItem.setSelected(true); } } else { curveManagementMenu.setEnabled(false); curveResetMenu.setEnabled(false); } showMultiAxesMenuItem.setSelected(isShowMultiaxes()); if (isPaused) { pauseMenuItem.setText("Paused"); } else { pauseMenuItem.setText("Click to Pause"); } pauseMenuItem.setSelected(isPaused); super.displayPopupMenu(x, y); }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public LegendPosition getLegendPosition() { if (isInternalLegendEnabled) { return LegendPosition.INTERNAL; } else {/*from w w w . j a v a 2 s . c o m*/ LegendTitle legend = getChart().getLegend(); if (legend != null) { if (legend.isVisible()) { if (legend.getPosition() == RectangleEdge.TOP) { return LegendPosition.TOP; } else if (legend.getPosition() == RectangleEdge.BOTTOM) { return LegendPosition.BOTTOM; } else if (legend.getPosition() == RectangleEdge.RIGHT) { return LegendPosition.RIGHT; } else if (legend.getPosition() == RectangleEdge.LEFT) { return LegendPosition.LEFT; } } } } return LegendPosition.NONE; }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override protected void displayPopupMenu(int x, int y) { LegendTitle legend = getChart().getLegend(); if (legend != null) { boolean isVisable = legend.isVisible(); RectangleEdge location = legend.getPosition(); if (isVisable) { if (location.equals(RectangleEdge.BOTTOM)) { legendBottom.setSelected(true); legendNone.setSelected(false); legendInternal.setSelected(false); legendRight.setSelected(false); } else if (isVisable && location.equals(RectangleEdge.RIGHT)) { legendRight.setSelected(true); legendNone.setSelected(false); legendInternal.setSelected(false); legendBottom.setSelected(false); }/* ww w.j a va 2 s .c om*/ } else { if (isInternalLegendEnabled) { legendNone.setSelected(false); legendInternal.setSelected(true); legendRight.setSelected(false); legendBottom.setSelected(false); } else { legendNone.setSelected(true); legendInternal.setSelected(false); legendRight.setSelected(false); legendBottom.setSelected(false); } } } XYDataset dataset = getChart().getXYPlot().getDataset(); curveManagementMenu.removeAll(); if (dataset.getSeriesCount() > 0) { curveManagementMenu.setEnabled(true); JMenuItem focusNoneCurveItem = new JRadioButtonMenuItem(); focusNoneCurveItem.setText("None"); focusNoneCurveItem.setActionCommand(UNFOCUS_CURVE_COMMAND); focusNoneCurveItem.addActionListener(this); curveManagementMenu.add(focusNoneCurveItem); boolean isCurveFocused = false; for (int i = 0; i < dataset.getSeriesCount(); i++) { String seriesKey = (String) dataset.getSeriesKey(i); JMenuItem focusOnCurveItem = new JRadioButtonMenuItem(); focusOnCurveItem.setText(seriesKey); focusOnCurveItem.setActionCommand(FOCUS_ON_COMMAND + "-" + seriesKey); focusOnCurveItem.addActionListener(this); curveManagementMenu.add(focusOnCurveItem); if (i == selectedSeriesIndex) { focusOnCurveItem.setSelected(true); isCurveFocused = true; } } if (!isCurveFocused) { focusNoneCurveItem.setSelected(true); } } else { curveManagementMenu.setEnabled(false); } // addMaskMenu(x, y); super.displayPopupMenu(x, y); }