List of usage examples for java.awt Color LIGHT_GRAY
Color LIGHT_GRAY
To view the source code for java.awt Color LIGHT_GRAY.
Click Source Link
From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java
public FieldViewPanel(PlotVisitList plotVisitList, Map<Integer, Trait> traitMap, SeparatorVisibilityOption visible, SimplePlotCellRenderer plotRenderer, Component... extras) { super(new BorderLayout()); this.plotVisitList = plotVisitList; this.traitMap = traitMap; trial = plotVisitList.getTrial();/*from w w w. j av a2 s. co m*/ fieldLayoutTableModel.setTrial(trial); int rowHeight = fieldLayoutTable.getRowHeight(); fieldLayoutTable.setRowHeight(4 * rowHeight); fieldLayoutTable.setCellSelectionEnabled(true); fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE fieldLayoutTable.setAutoCreateRowSorter(false); Map<Integer, Plot> plotById = new HashMap<>(); FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(), trial.getPlotIdentSummary(), plotVisitList.getPlots(), plotById); KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId, plotIdLayout.xsize, plotIdLayout.ysize); kdxFieldLayout.warning = plotIdLayout.warning; String displayName = null; for (VisitOrder2D vo : VisitOrder2D.values()) { if (vo.imageId == plotIdLayout.imageId) { displayName = vo.displayName; break; } } // VisitOrder2D vo = plotVisitList.getVisitOrder(); KDClientUtils.initAction(plotIdLayout.imageId, changeCollectionOrder, displayName); hasUserPlotId = lookForUserPlotIdPresent(plotById, plotIdLayout, kdxFieldLayout); this.plotCellRenderer = plotRenderer; plotCellRenderer.setShowUserPlotId(hasUserPlotId); plotCellRenderer.setPlotXYprovider(getXYprovider()); plotCellRenderer.setPlotVisitList(plotVisitList); fieldLayoutTable.setDefaultRenderer(Plot.class, plotCellRenderer); fieldLayoutTable.setCellSelectionEnabled(true); fieldLayoutTableModel.setFieldLayout(kdxFieldLayout); if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) { warningMessage.setText(kdxFieldLayout.warning); } else { warningMessage.setText(""); } fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fieldLayoutTable.getTableHeader().setReorderingAllowed(false); fieldLayoutTable.setCellSelectionEnabled(true); StringBuilder naming = new StringBuilder(); String nameForRow = plotVisitList.getTrial().getNameForRow(); if (!Check.isEmpty(nameForRow)) { naming.append(nameForRow); } String nameForCol = plotVisitList.getTrial().getNameForColumn(); if (!Check.isEmpty(nameForCol)) { if (naming.length() > 0) { naming.append('/'); } naming.append(nameForCol); } fieldTableScrollPane = new JScrollPane(fieldLayoutTable); if (naming.length() > 0) { JLabel cornerLabel = new JLabel(naming.toString()); fieldTableScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, cornerLabel); } fieldTableScrollPane.setRowHeaderView(rowHeaderTable); // fieldLayoutTable.setRowHeaderTable(rowHeaderTable); // Box extra = Box.createHorizontalBox(); // extra.add(new JButton(changeCollectionOrder)); // if (extras != null && extras.length > 0) { // extra.add(Box.createHorizontalStrut(8)); // for (Component c : extras) { // extra.add(c); // } // } // extra.add(Box.createHorizontalGlue()); switch (visible) { case NOTVISIBLE: break; case VISIBLE: default: Box top = Box.createHorizontalBox(); top.setOpaque(true); top.setBackground(Color.LIGHT_GRAY); top.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); JLabel label = new JLabel("Field"); label.setForeground(Color.DARK_GRAY); label.setFont(label.getFont().deriveFont(Font.BOLD)); top.add(label); top.add(new JButton(changeCollectionOrder)); if (extras != null && extras.length > 0) { top.add(Box.createHorizontalStrut(8)); for (Component c : extras) { top.add(c); } } add(top, BorderLayout.NORTH); break; } add(fieldTableScrollPane, BorderLayout.CENTER); add(warningMessage, BorderLayout.SOUTH); }
From source file:gg.view.accountsbalances.GraphAccountsBalancesTopComponent.java
/** * Displays the accounts' balances by period * @param balances Accounts' balances//w w w. java2s.c om */ 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:ro.nextreports.designer.querybuilder.SQLViewPanel.java
private void initUI() { sqlEditor = new Editor() { public void afterCaretMove() { removeHighlightErrorLine();//from w w w .j a v a 2 s. co m } }; this.queryArea = sqlEditor.getEditorPanel().getEditorPane(); queryArea.setText(DEFAULT_QUERY); errorPainter = new javax.swing.text.Highlighter.HighlightPainter() { @Override public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { try { Rectangle r = c.modelToView(c.getCaretPosition()); g.setColor(Color.RED.brighter().brighter()); g.fillRect(0, r.y, c.getWidth(), r.height); } catch (BadLocationException e) { // ignore } } }; ActionMap actionMap = sqlEditor.getEditorPanel().getEditorPane().getActionMap(); // create the toolbar JToolBar toolBar = new JToolBar(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); toolBar.setBorderPainted(false); // add cut action Action cutAction = actionMap.get(BaseEditorKit.cutAction); cutAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("cut")); cutAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.cut")); toolBar.add(cutAction); // add copy action Action copyAction = actionMap.get(BaseEditorKit.copyAction); copyAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("copy")); copyAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.copy")); toolBar.add(copyAction); // add paste action Action pasteAction = actionMap.get(BaseEditorKit.pasteAction); pasteAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("paste")); pasteAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqlviewpanel.paste")); toolBar.add(pasteAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add undo action Action undoAction = actionMap.get(BaseEditorKit.undoAction); undoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("undo")); undoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("undo")); toolBar.add(undoAction); // add redo action Action redoAction = actionMap.get(BaseEditorKit.redoAction); redoAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("redo")); redoAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("redo")); toolBar.add(redoAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add find action Action findReplaceAction = actionMap.get(BaseEditorKit.findReplaceAction); findReplaceAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("find")); findReplaceAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("sqleditor.findReplaceActionName")); toolBar.add(findReplaceAction); // add separator SwingUtil.addCustomSeparator(toolBar); // add run action runAction = new SQLRunAction(); runAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run")); runAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4"))); runAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " (" + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")"); // runAction is globally registered in QueryBuilderPanel ! toolBar.add(runAction); // ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(buttonsPanel); // create the table resultTable = new JXTable(); resultTable.setDefaultRenderer(Integer.class, new ToStringRenderer()); // to remove thousand separators resultTable.setDefaultRenderer(Long.class, new ToStringRenderer()); resultTable.setDefaultRenderer(Date.class, new DateRenderer()); resultTable.setDefaultRenderer(Double.class, new DoubleRenderer()); resultTable.addMouseListener(new CopyTableMouseAdapter(resultTable)); TableUtil.setRowHeader(resultTable); resultTable.setColumnControlVisible(true); // resultTable.getTableHeader().setReorderingAllowed(false); resultTable.setHorizontalScrollEnabled(true); // highlight table Highlighter alternateHighlighter = HighlighterFactory.createAlternateStriping(Color.WHITE, ColorUtil.PANEL_BACKROUND_COLOR); Highlighter nullHighlighter = new TextHighlighter(ResultSetTableModel.NULL_VALUE, Color.YELLOW.brighter()); Highlighter blobHighlighter = new TextHighlighter(ResultSetTableModel.BLOB_VALUE, Color.GRAY.brighter()); Highlighter clobHighlighter = new TextHighlighter(ResultSetTableModel.CLOB_VALUE, Color.GRAY.brighter()); resultTable.setHighlighters(alternateHighlighter, nullHighlighter, blobHighlighter, clobHighlighter); resultTable.setBackground(ColorUtil.PANEL_BACKROUND_COLOR); resultTable.setGridColor(Color.LIGHT_GRAY); resultTable.setRolloverEnabled(true); resultTable.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.66); split.setOneTouchExpandable(true); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridBagLayout()); topPanel.add(toolBar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); topPanel.add(sqlEditor, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); JScrollPane scrPanel = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); statusPanel = new SQLStatusPanel(); bottomPanel.add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); bottomPanel.add(statusPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); split.setTopComponent(topPanel); split.setBottomComponent(bottomPanel); split.setDividerLocation(400); setLayout(new BorderLayout()); this.add(split, BorderLayout.CENTER); }
From source file:com.rapidminer.gui.plotter.charts.HistogramChart.java
@Override protected void updatePlotter() { prepareData();/*w ww .j a v a2 s .c o m*/ String maxClassesProperty = ParameterService .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT); int maxClasses = 20; try { if (maxClassesProperty != null) { maxClasses = Integer.parseInt(maxClassesProperty); } } catch (NumberFormatException e) { // LogService.getGlobal().log("Deviation plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", // LogService.WARNING); LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.HistogramChart.parsing_property_error"); } int categoryCount = this.histogramDataset.getSeriesCount(); boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend; JFreeChart chart = ChartFactory.createHistogram(null, // title "Value", "Frequency", histogramDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips false); // urls XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setBackgroundPaint(Color.WHITE); plot.setForegroundAlpha(this.opaqueness); XYBarRenderer renderer = new XYBarRenderer(); if (histogramDataset.getSeriesCount() == 1) { renderer.setSeriesPaint(0, ColorProvider.reduceColorBrightness(Color.RED)); renderer.setSeriesFillPaint(0, ColorProvider.reduceColorBrightness(Color.RED)); } else { for (int i = 0; i < histogramDataset.getSeriesCount(); i++) { Color color = getColorProvider(true) .getPointColor((double) i / (double) (histogramDataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setBarPainter(new RapidXYBarPainter()); // renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); plot.setRenderer(renderer); plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); setRange(plot.getDomainAxis()); // display correct x-Axis labels int count = histogramDataset.getSeriesCount(); if (count > 0) { String key = histogramDataset.getSeriesKey(0).toString(); int index = this.dataTable.getColumnIndex(key); if (index >= 0) { // Correctly displays nominal values on x-axis if (count == 1 && this.dataTable.isNominal(index)) { String[] values = new String[dataTable.getNumberOfValues(index)]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(index, i); } plot.setDomainAxis(new SymbolAxis(key, values)); } // Correctly displays dates on x-axis if (this.dataTable.isDateTime(index)) { boolean applyDateAxis = true; if (count > 1) { for (int i = 1; i < count; i++) { index = this.dataTable.getColumnIndex(histogramDataset.getSeriesKey(i).toString()); if (index < 0 || !this.dataTable.isDateTime(index)) { applyDateAxis = false; break; } } } if (applyDateAxis) { DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(Tools.DATE_TIME_FORMAT.get()); plot.setDomainAxis(dateAxis); } } } // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } } // set the background color for the chart... chart.setBackgroundPaint(Color.white); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } AbstractChartPanel panel = getPlotterPanel(); if (panel == null) { panel = createPanel(chart); } else { panel.setChart(chart); } // Disable zooming for Histogram-Charts panel.setRangeZoomable(false); panel.setDomainZoomable(false); // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); }
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 *//*from w w w. j av a 2s .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); }
From source file:com.rapidminer.gui.plotter.charts.DistributionPlotter.java
@Override public void updatePlotter() { JFreeChart chart = null;//from w w w .j a v a 2 s . c om Attribute attr = null; if (plotColumn != -1 && createFromModel) { attr = model.getTrainingHeader().getAttributes().get(model.getAttributeNames()[plotColumn]); } if (attr != null && attr.isNominal() && attr.getMapping().getValues().size() > MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES) { // showing no chart because of too many different values chart = new JFreeChart(new Plot() { private static final long serialVersionUID = 1L; @Override public String getPlotType() { return "empty"; } @Override public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { String msg = I18N.getGUILabel("plotter_panel.too_many_nominals", "Distribution Plotter", DistributionPlotter.MAX_NUMBER_OF_DIFFERENT_NOMINAL_VALUES); g2.setColor(Color.BLACK); g2.setFont(g2.getFont().deriveFont(g2.getFont().getSize() * 1.35f)); g2.drawChars(msg.toCharArray(), 0, msg.length(), 50, (int) (area.getHeight() / 2 + 0.5d)); } }); AbstractChartPanel panel = getPlotterPanel(); // Chart Panel Settings if (panel == null) { panel = createPanel(chart); } else { panel.setChart(chart); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); } else { preparePlots(); if (!createFromModel && (groupColumn < 0 || plotColumn < 0)) { CategoryDataset dataset = new DefaultCategoryDataset(); chart = ChartFactory.createBarChart(null, // chart title "Not defined", // x axis label RANGE_AXIS_NAME, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); } else { try { if (model.isDiscrete(translateToModelColumn(plotColumn))) { chart = createNominalChart(); } else { chart = createNumericalChart(); } } catch (Exception e) { // do nothing - just do not draw the chart } } if (chart != null) { chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... Plot commonPlot = chart.getPlot(); commonPlot.setBackgroundPaint(Color.WHITE); if (commonPlot instanceof XYPlot) { XYPlot plot = (XYPlot) commonPlot; plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (dataTable != null) { if (dataTable.isDate(plotColumn) || dataTable.isDateTime(plotColumn)) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(plotColumn)); domainAxis.setTimeZone(com.rapidminer.tools.Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { NumberAxis numberAxis = new NumberAxis(dataTable.getColumnName(plotColumn)); plot.setDomainAxis(numberAxis); } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); // ranging if (dataTable != null) { Range range = getRangeForDimension(plotColumn); if (range != null) { plot.getDomainAxis().setRange(range, true, false); } range = getRangeForName(RANGE_AXIS_NAME); if (range != null) { plot.getRangeAxis().setRange(range, true, false); } } // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } } else if (commonPlot instanceof CategoryPlot) { CategoryPlot plot = (CategoryPlot) commonPlot; plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); } // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } AbstractChartPanel panel = getPlotterPanel(); // Chart Panel Settings if (panel == null) { panel = createPanel(chart); } else { panel.setChart(chart); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); } } }
From source file:net.frontlinesms.plugins.textforms.ui.BrowseDataPanelHandler.java
public void textfieldFocusLost(Object textfield) { String searchText = this.ui.getText(textfield); if (searchText == null || searchText.length() == 0) { this.ui.setText(textfield, TextFormsMessages.getMessageSearchAnswers()); this.ui.setForeground(Color.LIGHT_GRAY); } else {// w ww .ja v a 2 s . co m this.ui.setForeground(Color.BLACK); } }
From source file:org.mwc.debrief.track_shift.views.BaseStackedDotsView.java
/** * method to create a working plot (to contain our data) * /*w ww . j av a 2s. c om*/ * @return the chart, in it's own panel */ @SuppressWarnings("deprecation") protected void createStackedPlot() { // first create the x (time) axis final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss"); _df.setTimeZone(TimeZone.getTimeZone("GMT")); final DateAxis xAxis = new CachedTickDateAxis(""); xAxis.setDateFormatOverride(_df); Font tickLabelFont = new Font("Courier", Font.PLAIN, 13); xAxis.setTickLabelFont(tickLabelFont); xAxis.setTickLabelPaint(Color.BLACK); xAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); xAxis.setAutoTickUnitSelection(true); // create the special stepper plot _dotPlot = new XYPlot(); NumberAxis errorAxis = new NumberAxis("Error (" + getUnits() + ")"); Font axisLabelFont = new Font("Courier", Font.PLAIN, 16); errorAxis.setLabelFont(axisLabelFont); errorAxis.setTickLabelFont(tickLabelFont); _dotPlot.setRangeAxis(errorAxis); _dotPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); _dotPlot.setRenderer(new ColourStandardXYItemRenderer(null, null, _dotPlot)); _dotPlot.setRangeGridlinePaint(Color.LIGHT_GRAY); _dotPlot.setRangeGridlineStroke(new BasicStroke(2)); _dotPlot.setDomainGridlinePaint(Color.LIGHT_GRAY); _dotPlot.setDomainGridlineStroke(new BasicStroke(2)); // now try to do add a zero marker on the error bar final Paint thePaint = Color.DARK_GRAY; final Stroke theStroke = new BasicStroke(3); final ValueMarker zeroMarker = new ValueMarker(0.0, thePaint, theStroke); _dotPlot.addRangeMarker(zeroMarker); _linePlot = new XYPlot(); final NumberAxis absBrgAxis = new NumberAxis("Absolute (" + getUnits() + ")"); absBrgAxis.setLabelFont(axisLabelFont); absBrgAxis.setTickLabelFont(tickLabelFont); _linePlot.setRangeAxis(absBrgAxis); absBrgAxis.setAutoRangeIncludesZero(false); _linePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); final DefaultXYItemRenderer lineRend = new ColourStandardXYItemRenderer(null, null, _linePlot); lineRend.setPaint(Color.DARK_GRAY); _linePlot.setRenderer(lineRend); _linePlot.setDomainCrosshairVisible(true); _linePlot.setRangeCrosshairVisible(true); _linePlot.setDomainCrosshairPaint(Color.GRAY); _linePlot.setRangeCrosshairPaint(Color.GRAY); _linePlot.setDomainCrosshairStroke(new BasicStroke(3.0f)); _linePlot.setRangeCrosshairStroke(new BasicStroke(3.0f)); _linePlot.setRangeGridlinePaint(Color.LIGHT_GRAY); _linePlot.setRangeGridlineStroke(new BasicStroke(2)); _linePlot.setDomainGridlinePaint(Color.LIGHT_GRAY); _linePlot.setDomainGridlineStroke(new BasicStroke(2)); // and the plot object to display the cross hair value final XYTextAnnotation annot = new XYTextAnnotation("-----", 2, 2); annot.setTextAnchor(TextAnchor.TOP_LEFT); Font annotationFont = new Font("Courier", Font.BOLD, 16); annot.setFont(annotationFont); annot.setPaint(Color.DARK_GRAY); annot.setBackgroundPaint(Color.white); _linePlot.addAnnotation(annot); // give them a high contrast backdrop _dotPlot.setBackgroundPaint(Color.white); _linePlot.setBackgroundPaint(Color.white); // set the y axes to autocalculate _dotPlot.getRangeAxis().setAutoRange(true); _linePlot.getRangeAxis().setAutoRange(true); _combined = new CombinedDomainXYPlot(xAxis); _combined.add(_linePlot); _combined.add(_dotPlot); _combined.setOrientation(PlotOrientation.HORIZONTAL); // put the plot into a chart _myChart = new JFreeChart(null, null, _combined, true); final LegendItemSource[] sources = { _linePlot }; _myChart.getLegend().setSources(sources); _myChart.addProgressListener(new ChartProgressListener() { public void chartProgress(final ChartProgressEvent cpe) { if (cpe.getType() != ChartProgressEvent.DRAWING_FINISHED) return; // is hte line plot visible? if (!_showLinePlot.isChecked()) return; // double-check our label is still in the right place final double xVal = _linePlot.getRangeAxis().getLowerBound(); final double yVal = _linePlot.getDomainAxis().getUpperBound(); boolean annotChanged = false; if (annot.getX() != yVal) { annot.setX(yVal); annotChanged = true; } if (annot.getY() != xVal) { annot.setY(xVal); annotChanged = true; } // and write the text final String numA = MWC.Utilities.TextFormatting.GeneralFormat .formatOneDecimalPlace(_linePlot.getRangeCrosshairValue()); final Date newDate = new Date((long) _linePlot.getDomainCrosshairValue()); final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss"); _df.setTimeZone(TimeZone.getTimeZone("GMT")); final String dateVal = _df.format(newDate); final String theMessage = " [" + dateVal + "," + numA + "]"; if (!theMessage.equals(annot.getText())) { annot.setText(theMessage); annotChanged = true; } if (annotChanged) { _linePlot.removeAnnotation(annot); _linePlot.addAnnotation(annot); } } }); // and insert into the panel _holder.setChart(_myChart); // do a little tidying to reflect the memento settings if (!_showLinePlot.isChecked()) _combined.remove(_linePlot); if (!_showDotPlot.isChecked() && _showLinePlot.isChecked()) _combined.remove(_dotPlot); }
From source file:ecg.ecgshow.ECGShowUI.java
private void createPressureData(long timeZone) { PressureData = new JPanel(); PressuredateAxises = new DateAxis[1]; SystolicPressureSeries = new TimeSeries[2]; DiastolicPressureSeries = new TimeSeries[2]; TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); SystolicPressureSeries[0] = new TimeSeries(""); SystolicPressureSeries[0].setMaximumItemAge(timeZone); SystolicPressureSeries[0].setMaximumItemCount(500); SystolicPressureSeries[1] = new TimeSeries(""); SystolicPressureSeries[1].setMaximumItemAge(timeZone); SystolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(SystolicPressureSeries[0]); timeseriescollection.addSeries(SystolicPressureSeries[1]); PressuredateAxises[0] = new DateAxis(""); PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); PressuredateAxises[0].setTickLabelsVisible(true); PressuredateAxises[0].setVisible(false); DiastolicPressureSeries[0] = new TimeSeries(""); DiastolicPressureSeries[0].setMaximumItemAge(timeZone); DiastolicPressureSeries[0].setMaximumItemCount(500); DiastolicPressureSeries[1] = new TimeSeries(""); DiastolicPressureSeries[1].setMaximumItemAge(timeZone); DiastolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(DiastolicPressureSeries[0]); timeseriescollection.addSeries(DiastolicPressureSeries[1]); NumberAxis numberaxis = new NumberAxis("Pressure"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false);// ww w . j a va2 s . c o m numberaxis.setLowerBound(0D); numberaxis.setUpperBound(200D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); // xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5)); //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? )); chartpanel.setMouseZoomable(false); PressureData.add(chartpanel); }
From source file:edu.ucla.stat.SOCR.analyses.gui.NormalPower.java
/**Initialize the Analysis*/ public void init() { mapIndep = false;/*from w w w . j a va2s .c o m*/ showInput = false; super.init(); analysisType = AnalysisType.NORMAL_POWER; analysisName = "Normal Distribution Power Computation"; useInputExample = false; useLocalExample = false; useRandomExample = true; useServerExample = false; useStaticExample = new boolean[10]; depMax = 1; // max number of dependent var indMax = 1; // max number of independent var resultPanelTextArea.setFont(new Font(outputFontFace, Font.BOLD, outputFontSize)); frame = getFrame(this); setName(analysisName); // Create the toolBar ////////////////////////System.out.println("NormalPower init done variable"); toolBar = new JToolBar(); createActionComponents(toolBar); ////////////////////////System.out.println("NormalPower init this.getContentPane() = " + this.getContentPane()); this.getContentPane().add(toolBar, BorderLayout.NORTH); ////////////////////////System.out.println("NormalPower init start add listener"); checkSampleSizeBox.addActionListener(this); checkPowerBox.addActionListener(this); criticalValueBox.addActionListener(this); checkNE.addActionListener(this); checkLT.addActionListener(this); checkGT.addActionListener(this); sampleSizeText.addActionListener(this); sigmaText.addActionListener(this); sigmaText.addKeyListener(this); mu0Text.addActionListener(this); muAText.addActionListener(this); powerText.addActionListener(this); alphaCombo.addActionListener(this); sampleSizeBar.addAdjustmentListener(this); powerBar.addAdjustmentListener(this); checkSampleSizeBox.addMouseListener(this); checkPowerBox.addMouseListener(this); criticalValueBox.addMouseListener(this); checkNE.addMouseListener(this); checkLT.addMouseListener(this); checkGT.addMouseListener(this); sampleSizeText.addMouseListener(this); sigmaText.addMouseListener(this); mu0Text.addMouseListener(this); muAText.addMouseListener(this); powerText.addMouseListener(this); alphaCombo.addMouseListener(this); /********** alphaCombo is not editable because I can't get the critical point for ANY x values. **********/ alphaCombo.setEditable(false); alphaCombo.setSelectedIndex(1); tools2.remove(addButton2); tools2.remove(removeButton2); depLabel.setText(VARIABLE); indLabel.setText(""); listIndepRemoved.setBackground(Color.LIGHT_GRAY); mappingInnerPanel.remove(listIndepRemoved); addButton1.addActionListener(this); chartFactory = new Chart(); validate(); }