List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:com.openbravo.pos.util.JRViewer.java
/** This method is called from within the constructor to * initialize the form./*from w w w.j a v a 2s. c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; pnlMain = new javax.swing.JPanel(); scrollPane = new javax.swing.JScrollPane(); scrollPane.getHorizontalScrollBar().setUnitIncrement(5); scrollPane.getVerticalScrollBar().setUnitIncrement(5); pnlInScroll = new javax.swing.JPanel(); pnlPage = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); pnlLinks = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel9 = new javax.swing.JPanel(); lblPage = new PageRenderer(this); jToolBar = new javax.swing.JToolBar(); btnSave = new javax.swing.JButton(); btnPrint = new javax.swing.JButton(); btnReload = new javax.swing.JButton(); jSeparator1 = new javax.swing.JToolBar.Separator(); btnActualSize = new javax.swing.JToggleButton(); btnFitPage = new javax.swing.JToggleButton(); btnFitWidth = new javax.swing.JToggleButton(); jSeparator2 = new javax.swing.JToolBar.Separator(); btnZoomIn = new javax.swing.JButton(); cmbZoom = new javax.swing.JComboBox(); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < zooms.length; i++) { model.addElement("" + zooms[i] + "%"); } cmbZoom.setModel(model); btnZoomOut = new javax.swing.JButton(); jSeparator3 = new javax.swing.JToolBar.Separator(); btnFirst = new javax.swing.JButton(); btnPrevious = new javax.swing.JButton(); txtGoTo = new javax.swing.JTextField(); btnNext = new javax.swing.JButton(); btnLast = new javax.swing.JButton(); jSeparator4 = new javax.swing.JToolBar.Separator(); lblStatus = new javax.swing.JLabel(); setMinimumSize(new java.awt.Dimension(450, 150)); setPreferredSize(new java.awt.Dimension(450, 150)); setLayout(new java.awt.BorderLayout()); pnlMain.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent evt) { pnlMainComponentResized(evt); } }); pnlMain.setLayout(new java.awt.BorderLayout()); scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); pnlInScroll.setLayout(new java.awt.GridBagLayout()); pnlPage.setMinimumSize(new java.awt.Dimension(100, 100)); pnlPage.setPreferredSize(new java.awt.Dimension(100, 100)); pnlPage.setLayout(new java.awt.BorderLayout()); jPanel4.setMinimumSize(new java.awt.Dimension(100, 120)); jPanel4.setPreferredSize(new java.awt.Dimension(100, 120)); jPanel4.setLayout(new java.awt.GridBagLayout()); pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5)); pnlLinks.setOpaque(false); pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5)); pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { pnlLinksMousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { pnlLinksMouseReleased(evt); } }); pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { pnlLinksMouseDragged(evt); } }); pnlLinks.setLayout(null); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; jPanel4.add(pnlLinks, gridBagConstraints); jPanel5.setBackground(java.awt.Color.gray); jPanel5.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel5.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; jPanel4.add(jPanel5, gridBagConstraints); jPanel6.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel6.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; jPanel4.add(jPanel6, gridBagConstraints); jPanel7.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel7.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel4.add(jPanel7, gridBagConstraints); jPanel8.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel8.setPreferredSize(new java.awt.Dimension(5, 5)); jLabel1.setText("jLabel1"); jPanel8.add(jLabel1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; jPanel4.add(jPanel8, gridBagConstraints); jPanel9.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel9.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; jPanel4.add(jPanel9, gridBagConstraints); lblPage.setBackground(java.awt.Color.white); lblPage.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); lblPage.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel4.add(lblPage, gridBagConstraints); pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); pnlInScroll.add(pnlPage, gridBagConstraints); scrollPane.setViewportView(pnlInScroll); pnlMain.add(scrollPane, java.awt.BorderLayout.CENTER); jToolBar.setFloatable(false); jToolBar.setOpaque(false); btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/filesave.png"))); // NOI18N btnSave.setToolTipText(getBundleString("save")); btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } }); jToolBar.add(btnSave); btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/printer.png"))); // NOI18N btnPrint.setToolTipText(getBundleString("print")); btnPrint.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPrintActionPerformed(evt); } }); jToolBar.add(btnPrint); btnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/reload.png"))); // NOI18N btnReload.setToolTipText(getBundleString("reload")); btnReload.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnReloadActionPerformed(evt); } }); jToolBar.add(btnReload); jToolBar.add(jSeparator1); btnActualSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/mime.png"))); // NOI18N btnActualSize.setToolTipText(getBundleString("actual.size")); btnActualSize.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnActualSizeActionPerformed(evt); } }); jToolBar.add(btnActualSize); btnFitPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/mime2.png"))); // NOI18N btnFitPage.setToolTipText(getBundleString("fit.page")); btnFitPage.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFitPageActionPerformed(evt); } }); jToolBar.add(btnFitPage); btnFitWidth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/mime3.png"))); // NOI18N btnFitWidth.setToolTipText(getBundleString("fit.width")); btnFitWidth.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFitWidthActionPerformed(evt); } }); jToolBar.add(btnFitWidth); jToolBar.add(jSeparator2); btnZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/viewmag+.png"))); // NOI18N btnZoomIn.setToolTipText(getBundleString("zoom.in")); btnZoomIn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnZoomInActionPerformed(evt); } }); jToolBar.add(btnZoomIn); cmbZoom.setEditable(true); cmbZoom.setToolTipText(getBundleString("zoom.ratio")); cmbZoom.setMaximumSize(new java.awt.Dimension(80, 23)); cmbZoom.setMinimumSize(new java.awt.Dimension(80, 23)); cmbZoom.setPreferredSize(new java.awt.Dimension(80, 23)); cmbZoom.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cmbZoomItemStateChanged(evt); } }); cmbZoom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cmbZoomActionPerformed(evt); } }); jToolBar.add(cmbZoom); btnZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/viewmag-.png"))); // NOI18N btnZoomOut.setToolTipText(getBundleString("zoom.out")); btnZoomOut.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnZoomOutActionPerformed(evt); } }); jToolBar.add(btnZoomOut); jToolBar.add(jSeparator3); btnFirst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/2leftarrow.png"))); // NOI18N btnFirst.setToolTipText(getBundleString("first.page")); btnFirst.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFirstActionPerformed(evt); } }); jToolBar.add(btnFirst); btnPrevious .setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/1leftarrow.png"))); // NOI18N btnPrevious.setToolTipText(getBundleString("previous.page")); btnPrevious.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPreviousActionPerformed(evt); } }); jToolBar.add(btnPrevious); txtGoTo.setToolTipText(getBundleString("go.to.page")); txtGoTo.setMaximumSize(new java.awt.Dimension(40, 23)); txtGoTo.setMinimumSize(new java.awt.Dimension(40, 23)); txtGoTo.setPreferredSize(new java.awt.Dimension(40, 23)); txtGoTo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtGoToActionPerformed(evt); } }); jToolBar.add(txtGoTo); btnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/1rightarrow.png"))); // NOI18N btnNext.setToolTipText(getBundleString("next.page")); btnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextActionPerformed(evt); } }); jToolBar.add(btnNext); btnLast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/2rightarrow.png"))); // NOI18N btnLast.setToolTipText(getBundleString("last.page")); btnLast.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLastActionPerformed(evt); } }); jToolBar.add(btnLast); jToolBar.add(jSeparator4); lblStatus.setText("Page i of n"); jToolBar.add(lblStatus); pnlMain.add(jToolBar, java.awt.BorderLayout.NORTH); add(pnlMain, java.awt.BorderLayout.CENTER); }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
private void buildUI() { // First level in the panel has only 2 rows of 1 column panel.setLayout(new MigLayout("fill", "[grow, fill]", "[shrink]10[grow, fill]")); panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Now we build the upper part. // The "data" section. JPanel topPanel = new JPanel(new MigLayout("fill", "[115]10[fill, grow]", "[]10[]10[400]")); JLabel dataCategoryLabel = new JLabel("Data"); dataCategoryLabel.setFont(dataCategoryLabel.getFont().deriveFont(Font.BOLD)); topPanel.add(dataCategoryLabel, "span, wrap"); topPanel.add(new JLabel("Data source"), "gapleft 15"); topPanel.add(queryComboBox, "wrap"); JScrollPane tableScrollPane = new JScrollPane(resultTable); topPanel.add(headerLegendContainer, "gapleft 15, aligny top"); topPanel.add(tableScrollPane);/*from w ww. j a va 2s .c om*/ panel.add(topPanel, "wrap"); // Now the lower part. It has two parts. The options scrolling pane and the preview. JPanel bottomPanel = new JPanel( new MigLayout("fill, hidemode 2", "[grow]10[fill, shrinkprio 101]", "[fill]")); JLabel optionsCategoryLabel = new JLabel("Options"); optionsCategoryLabel.setFont(optionsCategoryLabel.getFont().deriveFont(Font.BOLD)); bottomPanel.add(optionsCategoryLabel); JLabel previewCategoryLabel = new JLabel("Preview"); previewCategoryLabel.setFont(previewCategoryLabel.getFont().deriveFont(Font.BOLD)); bottomPanel.add(previewCategoryLabel, "wrap"); JScrollPane optionsScrollPane = new JScrollPane(buildChartPrefsPanel(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); optionsScrollPane.setBorder(null); bottomPanel.add(optionsScrollPane, "push, gapleft 15"); JPanel chartAndErrorPanel = new JPanel(new BorderLayout()); chartAndErrorPanel.add(chartError, BorderLayout.NORTH); chartAndErrorPanel.add(chartPanel, BorderLayout.CENTER); bottomPanel.add(chartAndErrorPanel, "width 100%, alignx left, gapleft 15"); panel.add(bottomPanel, "height 100%"); toolBarBuilder.add(refreshDataAction); toolBarBuilder.add(revertToDefaultsAction); //Since the first button on the tool bar will be displayed this size will be the //same as the font size of a displayed button. If the button wasn't being displayed //the font size ends up incorrect float fontSize = toolBarBuilder.getToolbar().getComponentAtIndex(0).getFont().getSize(); toolBarBuilder.addSeparator(); toolBarBuilder.add(makeChartTypeButton("Bar", ChartType.BAR, BAR_CHART_ICON, fontSize)); toolBarBuilder.add(makeChartTypeButton("Pie", ChartType.PIE, PIE_CHART_ICON, fontSize)); toolBarBuilder .add(makeChartTypeButton("Category Line", ChartType.CATEGORY_LINE, LINE_CHART_ICON, fontSize)); toolBarBuilder.addSeparator(); toolBarBuilder.add(makeChartTypeButton("Line", ChartType.LINE, LINE_CHART_ICON, fontSize)); toolBarBuilder.add(makeChartTypeButton("Scatter", ChartType.SCATTER, SCATTER_CHART_ICON, fontSize)); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelData.java
/** * Initialises the interface of the data panel. *///from w w w .j a va2 s . c o m protected void initialize() { setLayout(null); lblExportChartTo = new JLabel("Export chart to ..."); lblExportChartTo.setBounds(436, 479, 144, 14); lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblExportChartTo.setVisible(false); add(lblExportChartTo); btnCsv = new JButton("CSV"); btnCsv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String csv; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("csv")) { csv = ""; } else { csv = ".csv"; } String csvPath = file.getAbsolutePath() + csv; OMRoom selectedRoom = (OMRoom) comboBoxRooms.getSelectedItem(); double[] selectedValues = selectedRoom.getValues(); File csvFile = new File(csvPath); try { FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); csvOutput.write("\"ID\";\"" + selectedRoom.getId() + "\""); csvOutput.newLine(); for (int i = 0; i < selectedValues.length; i++) { csvOutput.write("\"" + i + "\";\"" + (int) selectedValues[i] + "\""); csvOutput.newLine(); } JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success", JOptionPane.INFORMATION_MESSAGE); csvOutput.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnCsv.setBounds(590, 475, 70, 23); btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnCsv.setVisible(false); add(btnCsv); btnPdf = new JButton("PDF"); btnPdf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf")); fileDialog.showSaveDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String pdf; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("pdf")) { pdf = ""; } else { pdf = ".pdf"; } String pdfPath = file.getAbsolutePath() + pdf; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); String title = building.getName(); OMRoom selectedRoom = (OMRoom) comboBoxRooms.getSelectedItem(); JFreeChart chart = OMCharts.createRoomChart(title, selectedRoom, false); int height = (int) PageSize.A4.getWidth(); int width = (int) PageSize.A4.getHeight(); try { OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title); JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success", JOptionPane.INFORMATION_MESSAGE); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed", JOptionPane.ERROR_MESSAGE); ioe.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!", "Failed", JOptionPane.ERROR_MESSAGE); } } }); btnPdf.setBounds(670, 475, 70, 23); btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnPdf.setVisible(false); add(btnPdf); lblSelectProject = new JLabel("Select Project"); lblSelectProject.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectProject.setBounds(10, 65, 132, 14); add(lblSelectProject); lblSelectRoom = new JLabel("Select Room"); lblSelectRoom.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectRoom.setBounds(10, 94, 132, 14); add(lblSelectRoom); panelData = new JPanel(); panelData.setBounds(10, 118, 730, 347); add(panelData); btnRefresh = new JButton("Load"); btnRefresh.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("") && !txtOmbFile.getText().equals(" ")) { txtOmbFile.setBackground(Color.WHITE); String ombPath = txtOmbFile.getText(); String omb; String[] tmpFileName = ombPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(ombPath + omb); setOmbFile(ombPath + omb); File ombFile = new File(ombPath + omb); if (ombFile.exists()) { txtOmbFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxProjects.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); btnPdf.setVisible(false); btnCsv.setVisible(false); lblExportChartTo.setVisible(false); progressBar.setVisible(true); progressBar.setStringPainted(true); progressBar.setIndeterminate(true); refreshProjectsTask = new RefreshProjects(); refreshProjectsTask.execute(); } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmbFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); btnRefresh.setBounds(616, 61, 124, 23); add(btnRefresh); btnMaximize = new JButton("Fullscreen"); btnMaximize.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxRooms.isEnabled()) { if (comboBoxRooms.getSelectedItem() != null) { OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); String title = building.getName(); OMRoom room = (OMRoom) comboBoxRooms.getSelectedItem(); panelRoom = createRoomPanel(title, room, false, false); JFrame chartFrame = new JFrame(); JPanel chartPanel = createRoomPanel(title, room, false, true); chartFrame.getContentPane().add(chartPanel); chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight()); chartFrame.setTitle("OM Simulation Tool: " + title + ", Room " + room.getId()); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } } } }); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setVisible(false); add(btnMaximize); comboBoxProjects = new JComboBox<OMBuilding>(); comboBoxProjects.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); comboBoxProjects.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { boolean b = false; Color c = null; if (comboBoxProjects.isEnabled()) { if (comboBoxProjects.getSelectedItem() != null) { b = true; c = Color.WHITE; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); comboBoxRooms.removeAllItems(); for (int i = 0; i < building.getRooms().length; i++) { comboBoxRooms.addItem(building.getRooms()[i]); } for (int i = 0; i < building.getCellars().length; i++) { comboBoxRooms.addItem(building.getCellars()[i]); } for (int i = 0; i < building.getMiscs().length; i++) { comboBoxRooms.addItem(building.getMiscs()[i]); } } else { b = false; c = null; } } else { b = false; c = null; } lblSelectRoom.setEnabled(b); panelData.setEnabled(b); btnMaximize.setVisible(b); comboBoxRooms.setEnabled(b); panelData.setBackground(c); } }); comboBoxProjects.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { boolean b = false; Color c = null; if (comboBoxProjects.isEnabled()) { if (comboBoxProjects.getSelectedItem() != null) { b = true; c = Color.WHITE; OMBuilding building = (OMBuilding) comboBoxProjects.getSelectedItem(); comboBoxRooms.removeAllItems(); for (int i = 0; i < building.getRooms().length; i++) { comboBoxRooms.addItem(building.getRooms()[i]); } for (int i = 0; i < building.getCellars().length; i++) { comboBoxRooms.addItem(building.getCellars()[i]); } for (int i = 0; i < building.getMiscs().length; i++) { comboBoxRooms.addItem(building.getMiscs()[i]); } } else { b = false; c = null; } } else { b = false; c = null; } lblSelectRoom.setEnabled(b); panelData.setEnabled(b); btnMaximize.setVisible(b); comboBoxRooms.setEnabled(b); panelData.setBackground(c); } }); comboBoxProjects.setBounds(152, 61, 454, 22); add(comboBoxProjects); comboBoxRooms = new JComboBox<OMRoom>(); comboBoxRooms.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); comboBoxRooms.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxRooms.isEnabled()) { if (comboBoxRooms.getSelectedItem() != null) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); remove(panelData); comboBoxRooms.setEnabled(false); refreshChartsTask = new RefreshCharts(); refreshChartsTask.execute(); } } } }); comboBoxRooms.setBounds(152, 90, 454, 22); add(comboBoxRooms); progressBar = new JProgressBar(); progressBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); progressBar.setBounds(10, 475, 730, 23); progressBar.setVisible(false); add(progressBar); lblSelectRoom.setEnabled(false); panelData.setEnabled(false); comboBoxRooms.setEnabled(false); lblHelp = new JLabel( "Select an OMB-Object file to analyse its data. You can inspect radon concentration for each room."); lblHelp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblHelp.setForeground(Color.GRAY); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); txtOmbFile = new JTextField(); txtOmbFile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); txtOmbFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { setOmbFile(txtOmbFile.getText()); } }); txtOmbFile.setBounds(152, 33, 454, 20); add(txtOmbFile); txtOmbFile.setColumns(10); btnBrowse = new JButton("Browse"); btnBrowse.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String omb; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("omb")) { omb = ""; } else { omb = ".omb"; } txtOmbFile.setText(file.getAbsolutePath() + omb); setOmbFile(file.getAbsolutePath() + omb); } } }); btnBrowse.setBounds(616, 32, 124, 23); add(btnBrowse); lblSelectOmbfile = new JLabel("Select OMB-File"); lblSelectOmbfile.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); lblSelectOmbfile.setBounds(10, 36, 132, 14); add(lblSelectOmbfile); }
From source file:net.minelord.gui.panes.IRCPane.java
public void startClient(final String nick) { IRCLog = new ArrayList<String>(); SwingUtilities.invokeLater(new Runnable() { @Override//ww w . java2 s . c o m public void run() { text = new JEditorPane("text/html", "<HTML>"); text.setEditable(false); kit = new HTMLEditorKit(); text.setEditorKit(kit); client.connect("irc.liberty-unleashed.co.uk", "#moomoohk", nick, instance); scroller = new JScrollPane(text); text.setEditable(false); connect(); scroller.setBounds(20, 20, 810, 250); add(scroller); input = new JTextField(); input.setBounds(20, 270, 810, 30); Color bgColor = Color.gray.darker().darker(); UIDefaults defaults = new UIDefaults(); defaults.put("EditorPane[Enabled].backgroundPainter", bgColor); text.putClientProperty("Nimbus.Overrides", defaults); text.putClientProperty("Nimbus.Overrides.InheritDefaults", true); text.setBackground(bgColor); input.setBackground(Color.gray); input.setForeground(Color.gray.darker().darker().darker()); input.setEnabled(false); text.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (event.getDescription().charAt(0) == '#') { String[] params = { event.getDescription() }; IRCCommand.getCommand("/join").execute(client, params); } else OSUtils.browse(event.getURL().toString()); } } }); text.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent paramFocusEvent) { } @Override public void focusGained(FocusEvent paramFocusEvent) { input.requestFocus(); } }); scroller.setViewportView(text); add(input); input.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent arg0) { } @Override public void keyReleased(KeyEvent arg0) { if (arg0.getKeyCode() == 10) { if (input.getText().length() > 0) { lastCommandSelector = lastCommands.size(); lastCommands.add(input.getText()); } sendMessage(input.getText()); input.setText(""); } if (arg0.getKeyCode() == 27) input.setText(""); if (arg0.getKeyCode() == 17) { int before = input.getText().length(); if (input.getText().charAt(0) == '/') { input.setText(completeNick(input.getText())); input.select( input.getText().length() - completeNick(input.getText()).length() + before, input.getText().length()); } else { input.setText(completeCommand(input.getText())); input.select(input.getText().length() - completeCommand(input.getText()).length() + before, input.getText().length()); } } if (arg0.getKeyCode() == 38) if (lastCommandSelector > 0) { lastCommandSelector--; input.setText(lastCommands.get(lastCommandSelector)); } if (arg0.getKeyCode() == 40) if (lastCommandSelector < lastCommands.size()) { lastCommandSelector++; if (lastCommandSelector == lastCommands.size()) input.setText(""); if (lastCommandSelector < lastCommands.size()) input.setText(lastCommands.get(lastCommandSelector)); return; } } @Override public void keyPressed(KeyEvent arg0) { } }); } }); }
From source file:com.projity.pm.graphic.gantt.GanttRenderer.java
public void paintNonWorkingDays(Graphics2D g2, Rectangle bounds) { BarFormat calFormat = getCalendarFormat(); if (calFormat == null) return;//from w ww.j ava2 s .c om //non working days Color oldColor = g2.getColor(); Paint oldPaint = g2.getPaint(); CoordinatesConverter coord = ((GanttParams) graphInfo).getCoord(); Project project = coord.getProject(); WorkingCalendar wc = (WorkingCalendar) project.getWorkCalendar(); if (coord.getTimescaleManager().isShowWholeDays()) { boolean useScale2 = coord.getTimescaleManager().getCurrentScaleIndex() == 0; //valid only for current time scales TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), useScale2); long startNonworking = -1L, endNonWorking = -1L; Calendar cal = DateTime.calendarInstance(); PredefinedPaint paint = (PredefinedPaint) calFormat.getMiddle().getPaint();//new PredefinedPaint(PredefinedPaint.DOT_LINE,Colors.VERY_LIGHT_GRAY,Color.WHITE); paint.applyPaint(g2, useTextures()); while (i.hasNext()) { TimeInterval interval = i.next(); long s = interval.getStart(); if (CalendarService.getInstance().getDay(wc, s).isWorking()) { if (startNonworking != -1L) { drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2); startNonworking = endNonWorking = -1L; } } else { if (startNonworking == -1L) startNonworking = s; endNonWorking = s; } } if (startNonworking != -1L) { drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2); startNonworking = endNonWorking = -1L; } } if (container != null) { //scale2 separation lines TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), true); g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GRAY, g2.getBackground())); while (i.hasNext()) { TimeInterval interval = i.next(); int startX = (int) Math.round(coord.toX(interval.getStart())); g2.drawLine(startX, bounds.y, startX, bounds.y + bounds.height); } //project start int projectStartX = (int) Math.round(coord.toX(project.getStart())); if (projectStartX >= bounds.getX() && projectStartX <= bounds.getMaxX()) { g2.setPaint(new PredefinedPaint(PredefinedPaint.DASH_LINE, Color.GRAY, g2.getBackground())); g2.drawLine(projectStartX, bounds.y, projectStartX, bounds.y + bounds.height); } //project start long statusDate = project.getStatusDate(); if (statusDate != 0) { int statusDateX = (int) Math.round(coord.toX(statusDate)); if (statusDateX >= bounds.getX() && statusDateX <= bounds.getMaxX()) { g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GREEN, g2.getBackground())); g2.drawLine(statusDateX, bounds.y, statusDateX, bounds.y + bounds.height); } } if (oldColor != null) g2.setColor(oldColor); if (oldPaint != null) g2.setPaint(oldPaint); } }
From source file:app.RunApp.java
/** * Initializes the default configuration of the app *//*from w w w .j a va2 s . c om*/ private void initConfig() { /* * Preprocess */ buttonGroup1.add(radioRandomHoldout); radioRandomHoldout.setToolTipText("Split the dataset into random train and test files"); textRandomHoldout.setToolTipText("Percentage of train instances"); buttonGroup1.add(radioIterativeStratifiedHoldout); radioIterativeStratifiedHoldout .setToolTipText("Split the dataset into train and test files by Iterative stratified method"); textIterativeStratifiedHoldout.setToolTipText("Percentage of train instances"); buttonGroup1.add(radioLPStratifiedHoldout); radioLPStratifiedHoldout .setToolTipText("Split the dataset into train and test files by Label Powerset stratified method"); textLPStratifiedHoldout.setToolTipText("Percentage of train instances"); buttonGroup1.add(radioRandomCV); radioRandomCV.setToolTipText("Generates random cross-validation files for selected number of folds"); textRandomCV.setToolTipText("Number of folds for cross-validation"); buttonGroup1.add(radioIterativeStratifiedCV); radioIterativeStratifiedCV.setToolTipText( "Generates Iterative stratified cross-validation files for selected number of folds"); textIterativeStratifiedCV.setToolTipText("Number of folds for cross-validation"); buttonGroup1.add(radioLPStratifiedCV); radioLPStratifiedCV.setToolTipText( "Generates Label Powerset stratified cross-validation files for selected number of folds"); textLPStratifiedCV.setToolTipText("Number of folds for cross-validation"); buttonGroup1.add(radioNoSplit); radioNoSplit.setToolTipText("Not generate any partition of the dataset"); buttonGroup2.add(radioBRFS); radioBRFS.setToolTipText("Feature selection by Binary Relevance Feature Selection method"); textBRFS.setToolTipText("Number of features to select"); labelBRFSComb.setToolTipText("Combiantion approach mode"); jComboBoxBRFSComb.setToolTipText("<html>Combiantion approach mode: <br>" + "max: maximum <br>" + "avg: average <br>" + "min: minumum </html>"); labelBRFSNorm.setToolTipText("Normalization mode"); jComboBoxBRFSNorm.setToolTipText("<html>Normalization mode: <br>" + "dl: divide by length <br>" + "dm: divide by maximum <br>" + "none: no normalization </html>"); labelBRFSOut.setToolTipText("Scoring mode"); jComboBoxBRFSOut.setToolTipText( "<html>Scoring mode: <br>" + "eval: evaluation score <br>" + "rank: ranking score </html>"); buttonGroup2.add(radioRandomFS); radioRandomFS.setToolTipText("Random selection of the features"); textRandomFS.setToolTipText("Number of features to select"); buttonGroup2.add(radioNoFS); radioNoFS.setToolTipText("No feature selection is done"); jButtonStartPreprocess.setToolTipText("Start preprocessing"); jButtonSaveDatasets.setToolTipText("Save dataset files in a folder"); jComboBoxSaveFormat.setToolTipText("Select Mulan or Meka format to save datasets"); buttonGroup3.add(radioNoIS); radioNoIS.setToolTipText("No instance selection is done"); buttonGroup3.add(radioRandomIS); radioRandomIS.setToolTipText("Random selection of the instances"); textRandomIS.setToolTipText("Number of instances to select"); radioRandomHoldout.setSelected(true); radioNoFS.setSelected(true); radioNoIS.setSelected(true); textRandomHoldout.setEnabled(true); textRandomHoldout.setEnabled(true); textIterativeStratifiedHoldout.setEnabled(false); textRandomCV.setEnabled(false); textIterativeStratifiedCV.setEnabled(false); /* * Transformations */ radioBRTrans.setSelected(true); buttonGroup4.add(radioBRTrans); radioBRTrans.setToolTipText("Generates a binary dataset for each label"); buttonGroup4.add(radioLPTrans); radioLPTrans.setToolTipText( "Generates a multi-class dataset where each class is each one of the labelsets in the MLDataset"); buttonGroup4.add(radioIncludeLabelsTrans); radioIncludeLabelsTrans.setToolTipText( "<html>Generates a binary dataset, replicating the instance, where each one is augmented <br> with a label name and the class indicates if the label was associated or not</html>"); radioIncludeLabelsTrans.setToolTipText( "<html>Generates a binary dataset where each instance is replicated as many times as the number of labels.<br>" + "Each new instance is augmented with a label name and the class indicates if the label was associated or not.</html>"); buttonGroup4.add(radioRemoveLabelsTrans); radioRemoveLabelsTrans.setToolTipText("Remove all the labels of the dataset"); jButtonStartTrans.setToolTipText("Start transformation"); jButtonSaveDatasetsTrans.setToolTipText("Save dataset files in a folder"); /* * Dependences */ buttonShowCoOcurrence.setToolTipText("Show graph with labels selected in table"); buttonShowMostFrequent.setToolTipText("Show graph with n most frequent labels"); textMostFrequent.setToolTipText("Number of most frequent labels to show"); buttonShowMostRelated.setToolTipText("Show graph with n most related labels"); textMostRelated.setToolTipText("Number of most related labels to show"); buttonShowMostFrequentURelated .setToolTipText("Show graph with n most frequent union n most related labels"); textMostFrequentURelated.setToolTipText("Show graph with n most frequent union n most related labels"); buttonShowHeatMap.setToolTipText("Show heatmap with labels selected in table"); buttonShowMostFrequentHeatMap.setToolTipText("Show heatmap with n most frequent labels"); textMostFrequentHeatMap.setToolTipText("Number of most frequent labels to show"); buttonShowMostRelatedHeatMap.setToolTipText("Show heatmap with n most related labels"); textMostRelatedHeatMap.setToolTipText("Number of most related labels to show"); buttonShowMostFrequentURelatedHeatMap .setToolTipText("Show heatmap with n most frequent union n most related labels"); textMostFrequentURelatedHeatMap .setToolTipText("Show graph with n most frequent union n most related labels"); jTableChiPhi = setChiPhiTableHelp(jTableChiPhi); jTableCoocurrences = setCoocurrenceTableHelp(jTableCoocurrences); jTableHeatmap = setHeatmapTableHelp(jTableHeatmap); initChiPhiJTable(); //Config jTable Co-ocurrence values jTableCoocurrences.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane scrollPane = new JScrollPane(jTableCoocurrences, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBounds(20, 20, 780, 390); jTableCoocurrences.setBorder(BorderFactory.createLineBorder(Color.black)); panelCoOcurrenceValues.add(scrollPane, BorderLayout.CENTER); //Config jTable heatmap values jTableHeatmap.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane = new JScrollPane(jTableHeatmap, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBounds(20, 20, 780, 390); jTableHeatmap.setBorder(BorderFactory.createLineBorder(Color.black)); panelHeatmapValues.add(scrollPane, BorderLayout.CENTER); createButtonExportDependencesTable(jTableChiPhi, fixedTableChiPhi, panelChiPhi, exportChiPhiTable, 710, 415, "ChiPhi"); // chiLabel and phiLabel values createButtonExportDependencesTable(jTableCoocurrences, fixedTableCoocurrences, panelCoOcurrenceValues, exportCoocurrenceTable, 710, 415, "Coocurrence");//graph values createButtonExportDependencesTable(jTableHeatmap, fixedTableHeatmap, panelHeatmapValues, exportHeatmapTable, 710, 415, "Heatmap");//heatmap values createButtonExportDependencesChart(panelCoOcurrence, exportCoocurrenceGraph, 720, 440); createButtonExportDependencesChart(panelHeatmapGraph, exportHeatmapGraph, 720, 440); Border border = BorderFactory.createLineBorder(Color.gray, 1); panelHeatmap.setBorder(border); jTableChiPhi.setBorder(border); jTableCoocurrences.setBorder(border); jTableHeatmap.setBorder(border); /* * Charts */ labelFrequencyChart = createJChart(panelExamplesPerLabel, "bar", "Frequency", "Labels", false, "Label frequency"); labelsetsFrequencyChart = createJChart(panelExamplesPerLabelset, "bar", "Frequency", "Labelsets", false, "Labelset frequency"); labelsHistogramChart = createJChart(panelLabelsPerExample, "bar", "Frequency", "Number of labels", false, "Labels histogram"); labelsBoxDiagram = createGraph(panelBoxDiagram); attributesBoxDiagram2 = createGraph(panelBoxDiagramAtt); IRInterClassChart = createJChart(panelIRperLabelInterClass, "bar", "IR inter-class", "Labels", false, "IR inter class"); IRIntraClassChart = createJChart(panelIRperLabelIntraClass, "bar", "IR intra-class", "Labels", false, "IR intra class"); IRLabelsetsChart = createJChart(panelIRperLabelset, "bar", "IR", "Labelsets", false, "IR per labelset"); jLabelIR.setVisible(false); /* * Metrics */ jTablePrincipal = setMetricsHelp(jTablePrincipal); createMetricsTable(jTablePrincipal, panelSummary, buttonAll, buttonNone, buttonInvert, buttonCalculate, buttonSave, buttonClear, 30, 190, 780, 280); //tab Database //35,155,500,355 jTableMulti = setMetricsHelp(jTableMulti); createMultiMetricsTable(jTableMulti, jPanelMulti, buttonAll, buttonNone, buttonInvert, buttonCalculate, buttonSave, 25, 15, 510, 420); //tab Multi jButtonSaveDatasets.setEnabled(false); jComboBoxSaveFormat.setEnabled(false); /* * Progress bar */ progressBar = new JProgressBar(0, 100); progressBar.setValue(0); progressFrame = new JFrame(); progressFrame.setBounds(this.getX() + this.getWidth() / 2 - 100, this.getY() + this.getHeight() / 2 - 15, 200, 30); progressFrame.setResizable(false); progressFrame.setUndecorated(true); progressFrame.add(progressBar); //Default tab TabPrincipal.setEnabledAt(1, false); TabPrincipal.setEnabledAt(2, false); TabPrincipal.setEnabledAt(3, false); TabPrincipal.setEnabledAt(4, false); TabPrincipal.setEnabledAt(5, false); TabPrincipal.setEnabledAt(6, true); //Multiple datasets table enabled TabPrincipal.setEnabledAt(7, false); }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCorrelationScatterPlot.java
private Color getColorForIHCResult(String result, IHCBiomarkerType biomarkerType) { switch (biomarkerType) { case BCL2:/*from w ww . j a v a2 s . co m*/ return BCL2ihcType.valueOf(result).getColor(); case EGFR: return EGFRihcType.valueOf(result).getColor(); case FAK: return FAKihcType.valueOf(result).getColor(); case HER2: return HER2ihcType.valueOf(result).getColor(); case KI67: return Ki67ihcType.valueOf(result).getColor(); case P27: return P27ihcType.valueOf(result).getColor(); case P53: return P53ihcType.valueOf(result).getColor(); case CYCLIN_D1: return CCND1ihcType.valueOf(result).getColor(); } return Color.GRAY; }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
JFreeChart actualLabChartRef(String demographicNo, String labType, String identifier, String testName, String patientName, String chartTitle) { org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); ArrayList<Map<String, Serializable>> list = CommonLabTestValues.findValuesForTest(labType, demographicNo, testName, identifier);/*from w w w . j a va2s. com*/ String typeYAxisName = ""; ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>(); String typeLegendName = "Lab Value"; typeYAxisName = "type Y"; boolean nameSet = false; TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class); for (Map mdb : list) { if (!nameSet) { typeYAxisName = (String) mdb.get("units"); typeLegendName = (String) mdb.get("testName"); newSeries.setKey(typeLegendName); nameSet = true; } newSeries.addOrUpdate(new Day((Date) mdb.get("collDateDate")), Double.parseDouble("" + mdb.get("result"))); log.debug("RANGE " + mdb.get("range")); if (mdb.get("range") != null) { String range = (String) mdb.get("range"); if (range.indexOf("-") != -1) { String[] sp = range.split("-"); double open = Double.parseDouble(sp[0]); double high = Double.parseDouble(sp[1]); double low = Double.parseDouble(sp[0]); double close = Double.parseDouble(sp[1]); double volume = 1045; dataItems.add(new OHLCDataItem(new Day((Date) mdb.get("collDateDate")).getStart(), open, high, low, close, volume)); } } } dataset.addSeries(newSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", typeYAxisName, dataset, true, true, true); XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setAutoRange(true); log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin() * 6); plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin() * 6); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 1.7); plot.getDomainAxis().setUpperMargin(0.9); plot.getDomainAxis().setLowerMargin(0.9); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); ValueAxis va = plot.getRangeAxis(); va.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance() XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00")); renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer; rend.setBaseShapesVisible(true); rend.setBaseShapesFilled(true); } plot.setRenderer(renderer); if (dataItems != null && dataItems.size() > 0) { OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]); XYDataset referenceRangeDataset = new DefaultOHLCDataset("Normal Reference Range", ohlc); plot.setDataset(1, referenceRangeDataset); plot.mapDatasetToRangeAxis(1, 0); plot.setRenderer(1, new HighLowRenderer()); } return chart; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
/** * Draws zoom rectangle (if present). The drawing is performed in XOR mode, therefore when this * method is called twice in a row, the second call will completely restore the state of the * canvas.//from w w w. j a va 2 s . co m * * @param g2 * the graphics device. * @param xor * use XOR for drawing? */ private void drawZoomRectangle(Graphics2D g2, boolean xor) { Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle"); if (zoomRectangle != null) { // fix rectangle parameters when chart is transformed zoomRectangle = coordinateTransformation.transformRectangle(zoomRectangle, this); if (!(coordinateTransformation instanceof NullCoordinateTransformation)) { g2 = coordinateTransformation.getTransformedGraphics(this); } if (xor) { // Set XOR mode to draw the zoom rectangle g2.setXORMode(Color.gray); } if ((Boolean) getChartFieldValueByName("fillZoomRectangle")) { g2.setPaint((Paint) getChartFieldValueByName("zoomFillPaint")); g2.fill(zoomRectangle); } else { g2.setPaint((Paint) getChartFieldValueByName("zoomOutlinePaint")); g2.draw(zoomRectangle); } if (xor) { // Reset to the default 'overwrite' mode g2.setPaintMode(); } } }
From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java
private JPanel createAdvancedTab() { JPanel jpAdvanced = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;//from w w w . ja va2 s. c om c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(8, 10, 2, 4); JLabel jlExpectHeaderInfoIcon = new JLabel(infoIcon); jlExpectHeaderInfoIcon .setToolTipText("<html>Ticking this checkbox may significantly improve performance when<br>" + "large volumes of data are sent to the remote server and a redirect<br>" + "from the original URL to the one specified by the server is likely.<br>" + "<br>" + "However, this checkbox <b>must not</b> be ticked to allow this activity<br>" + "to post updates to Twitter.</html>"); jpAdvanced.add(jlExpectHeaderInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(8, 0, 2, 8); cbSendHTTPExpectHeader = new JCheckBox("Send HTTP Expect request-header field"); jpAdvanced.add(cbSendHTTPExpectHeader, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowRedirectionOutputPortInfoIcon = new JLabel(infoIcon); jlShowRedirectionOutputPortInfoIcon .setToolTipText("<html>\"Redirection\" output port displays the URL of the final redirect<br>" + "that has yielded the output data on the \"Response Body\" port.</html>"); jpAdvanced.add(jlShowRedirectionOutputPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowRedirectionOutputPort = new JCheckBox("Show \"Redirection\" output port"); jpAdvanced.add(cbShowRedirectionOutputPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowActualUrlPortInfoIcon = new JLabel(infoIcon); jlShowActualUrlPortInfoIcon .setToolTipText("<html>\"Actual URL\" output port displays the URL used by the REST service<br>" + "with the actual parameter values.</html>"); jpAdvanced.add(jlShowActualUrlPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowActualUrlPort = new JCheckBox("Show \"Actual URL\" output port"); jpAdvanced.add(cbShowActualUrlPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlShowResponseHeadersPortInfoIcon = new JLabel(infoIcon); jlShowResponseHeadersPortInfoIcon .setToolTipText("<html>\"Response headers\" output port displays the HTTP headers<br>" + "received from the final (after redirection) HTTP call.</html>"); jpAdvanced.add(jlShowResponseHeadersPortInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbShowResponseHeadersPort = new JCheckBox("Show \"Response headers\" output port"); jpAdvanced.add(cbShowResponseHeadersPort, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.insets = new Insets(2, 10, 5, 4); JLabel jlEscapeParametersInfoIcon = new JLabel(infoIcon); jlEscapeParametersInfoIcon.setToolTipText("<html>Determines if parameters you pass to form the full URL<br>" + " of the REST service will be URL-escaped.</html>"); jpAdvanced.add(jlEscapeParametersInfoIcon, c); c.gridx++; c.weightx = 1.0; c.insets = new Insets(2, 0, 5, 8); cbEscapeParameters = new JCheckBox("Escape URL parameter values"); jpAdvanced.add(cbEscapeParameters, c); c.gridx = 0; c.gridy++; c.weightx = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(2, 10, 5, 4); JLabel jlHTTPHeadersInfoIcon = new JLabel(infoIcon); jlHTTPHeadersInfoIcon.setToolTipText("<html>Set additional HTTP headers</html>"); jpAdvanced.add(jlHTTPHeadersInfoIcon, c); c.gridx = 1; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(2, 10, 5, 4); addHeaderButton = new JButton("Add HTTP header"); addHeaderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { httpHeadersTableModel.addEmptyRow(); httpHeadersTable.getSelectionModel().setSelectionInterval(httpHeadersTableModel.getRowCount() - 1, httpHeadersTableModel.getRowCount() - 1); } }); removeHeaderButton = new JButton("Remove HTTP header"); removeHeaderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = httpHeadersTable.getSelectedRow(); httpHeadersTableModel.removeRow(row); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(addHeaderButton, FlowLayout.LEFT); buttonPanel.add(removeHeaderButton); jpAdvanced.add(buttonPanel, c); c.gridx = 1; c.gridy++; c.weightx = 0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(2, 10, 5, 4); httpHeadersTableModel = new HTTPHeadersTableModel(); httpHeadersTable = new JTable(httpHeadersTableModel); httpHeadersTable.setGridColor(Color.GRAY); httpHeadersTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setVisibleRowCount(httpHeadersTable, 3); JScrollPane headersTableScrollPane = new JScrollPane(httpHeadersTable); jpAdvanced.add(headersTableScrollPane, c); return (jpAdvanced); }