List of usage examples for java.awt Font SANS_SERIF
String SANS_SERIF
To view the source code for java.awt Font SANS_SERIF.
Click Source Link
From source file:com.fluidops.iwb.deepzoom.ImageLoader.java
private void generateIDCard(URI uri, Map<URI, Set<Value>> facets, String url, File file) { int width = 200; int height = 200; BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D ig2 = bi.createGraphics(); ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ig2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); /* Special ID card handling for certain entity types */ /* TODO: special images based on type if(facets.containsKey(RDF.TYPE)) {//w ww . ja va 2s .c om Set<Value> facet = facets.get(RDF.TYPE); for(Value v : facet) { if(v.equals(Vocabulary.DCAT_DATASET)) { Image img = null; try { img = ImageIO.read( new File( "webapps/ROOT/images/rdf.jpg" ) ); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error("Could not get image"); } ig2.drawImage( img, 0, 0, null ); break; } } } */ String label = EndpointImpl.api().getDataManager().getLabel(uri); Font font = new Font(Font.SANS_SERIF, Font.BOLD, 20); ig2.setFont(font); FontMetrics fontMetrics = ig2.getFontMetrics(); int labelwidth = fontMetrics.stringWidth(label); if (labelwidth >= width) { int fontsize = 20 * width / labelwidth; font = new Font(Font.SANS_SERIF, Font.BOLD, fontsize); ig2.setFont(font); fontMetrics = ig2.getFontMetrics(); } int x = (width - fontMetrics.stringWidth(label)) / 2; int y = (fontMetrics.getAscent() + (height - (fontMetrics.getAscent() + fontMetrics.getDescent())) / 2); ig2.setPaint(Color.black); ig2.drawString(label, x, y); BufferedOutputStream out; try { out = new BufferedOutputStream(new FileOutputStream(file)); ImageIO.write(bi, "PNG", out); out.flush(); out.close(); } catch (IOException e) { logger.error(e.getMessage(), e); } }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Create the JFreeChart.//from w w w . j av a 2 s .c o m * @param dataset * task list for the JFreeChart. * @return JFreeChart of tasks. */ private JFreeChart createChart(final IntervalCategoryDataset dataset) { final JFreeChart chart = ChartFactory.createGanttChart("", "", "", dataset, true, false, false); chart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.4); chart.getCategoryPlot().getDomainAxis().setLowerMargin(0); chart.getCategoryPlot().getDomainAxis().setUpperMargin(0); chart.getCategoryPlot().getDomainAxis().setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().getDomainAxis().setTickLabelInsets(new RectangleInsets(0, 0, 0, 0)); chart.getCategoryPlot().getDomainAxis() .setCategoryLabelPositions(new CategoryLabelPositions( new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1), new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 1))); return chart; }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setAlbumsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedAlbums(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ALBUM_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getAlbumsChart() .setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelData.java
/** * Initialises the interface of the data panel. *///from w w w. j a v a 2 s. com 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:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
public void updateEtResults(String carInfo, double[] etResults, String units) { String s60Text = "60 ft"; String s330Text = "330 ft"; String s660Text = "1/2 track"; String s1000Text = "1,000 ft"; String s1320Text = "1/4 mile"; String zTo60Text = "60 mph"; if (units.equalsIgnoreCase("km/h")) { s60Text = "18.3m"; s330Text = "100m"; s1000Text = "305m"; s1320Text = "402m"; zTo60Text = "97 km/h"; }//ww w . j ava 2 s . co m hpAxis.setLabel("Vehicle Speed (" + units + ")"); String[] car = carInfo.split(";"); car[0] = "LANE 1: " + car[0].substring(0, car[0].length() - 3) + " - ET: " + String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]) + " " + units; double ySpace = hpAxis.getUpperBound() / 25; double xMin = ((plot.getDomainAxis().getUpperBound() - plot.getDomainAxis().getLowerBound()) / 7) + plot.getDomainAxis().getLowerBound(); tqAxis.setRange(hpAxis.getLowerBound(), hpAxis.getUpperBound()); final XYAnnotation s60Marker = new XYDrawableAnnotation(etResults[0], etResults[1], 10, 10, cd); final XYTextAnnotation s60Label = new XYTextAnnotation(s60Text, etResults[0], (etResults[1] + ySpace)); s60Label.setPaint(RED); s60Label.setTextAnchor(TextAnchor.TOP_RIGHT); s60Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation s60Time = new XYTextAnnotation( String.format("%1.3f", etResults[0]) + "\" / " + String.format("%1.2f", etResults[1]), etResults[0], (etResults[1] - ySpace)); s60Time.setPaint(RED); s60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT); s60Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYAnnotation s330Marker = new XYDrawableAnnotation(etResults[2], etResults[3], 10, 10, cd); final XYTextAnnotation s330Label = new XYTextAnnotation(s330Text, etResults[2], (etResults[3] + ySpace)); s330Label.setPaint(RED); s330Label.setTextAnchor(TextAnchor.TOP_RIGHT); s330Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation s330Time = new XYTextAnnotation( String.format("%1.3f", etResults[2]) + "\" / " + String.format("%1.2f", etResults[3]), etResults[2], (etResults[3] - ySpace)); s330Time.setPaint(RED); s330Time.setTextAnchor(TextAnchor.BOTTOM_LEFT); s330Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYAnnotation s660Marker = new XYDrawableAnnotation(etResults[4], etResults[5], 10, 10, cd); final XYTextAnnotation s660Label = new XYTextAnnotation(s660Text, etResults[4], (etResults[5] + ySpace)); s660Label.setPaint(RED); s660Label.setTextAnchor(TextAnchor.TOP_RIGHT); s660Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation s660Time = new XYTextAnnotation( String.format("%1.3f", etResults[4]) + "\" / " + String.format("%1.2f", etResults[5]), etResults[4], (etResults[5] - ySpace)); s660Time.setPaint(RED); s660Time.setTextAnchor(TextAnchor.BOTTOM_LEFT); s660Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYAnnotation s1000Marker = new XYDrawableAnnotation(etResults[6], etResults[7], 10, 10, cd); final XYTextAnnotation s1000Label = new XYTextAnnotation(s1000Text, etResults[6], (etResults[7] + ySpace)); s1000Label.setPaint(RED); s1000Label.setTextAnchor(TextAnchor.TOP_RIGHT); s1000Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation s1000Time = new XYTextAnnotation( String.format("%1.3f", etResults[6]) + "\" / " + String.format("%1.2f", etResults[7]), etResults[6], (etResults[7] - ySpace)); s1000Time.setPaint(RED); s1000Time.setTextAnchor(TextAnchor.BOTTOM_LEFT); s1000Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYAnnotation s1320Marker = new XYDrawableAnnotation(etResults[8], etResults[9], 10, 10, cd); final XYTextAnnotation s1320Label = new XYTextAnnotation(s1320Text, etResults[8], (etResults[9] - ySpace)); s1320Label.setPaint(RED); s1320Label.setTextAnchor(TextAnchor.BOTTOM_CENTER); s1320Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation s1320Time = new XYTextAnnotation( String.format("%1.3f", etResults[8]) + "\" / " + String.format("%1.2f", etResults[9]), (etResults[8] - 0.2), etResults[9]); s1320Time.setPaint(RED); s1320Time.setTextAnchor(TextAnchor.CENTER_RIGHT); s1320Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation carText = new XYTextAnnotation(car[0], (plot.getDomainAxis().getUpperBound() - 0.2), (hpAxis.getLowerBound() + ySpace)); carText.setPaint(RED); carText.setTextAnchor(TextAnchor.BOTTOM_RIGHT); carText.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); final XYAnnotation zTo60Marker = new XYDrawableAnnotation(etResults[10], etResults[11], 10, 10, cdGreen); final XYTextAnnotation zTo60Label = new XYTextAnnotation(zTo60Text, etResults[10], (etResults[11] + ySpace)); zTo60Label.setPaint(GREEN); zTo60Label.setTextAnchor(TextAnchor.TOP_RIGHT); zTo60Label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); final XYTextAnnotation zTo60Time = new XYTextAnnotation((String.format("%1.3f", etResults[10]) + "\""), etResults[10], (etResults[11] - ySpace)); zTo60Time.setPaint(GREEN); zTo60Time.setTextAnchor(TextAnchor.BOTTOM_LEFT); zTo60Time.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 10)); plot.addAnnotation(s60Marker); plot.addAnnotation(s60Label); plot.addAnnotation(s60Time); plot.addAnnotation(s330Marker); plot.addAnnotation(s330Label); plot.addAnnotation(s330Time); plot.addAnnotation(s660Marker); plot.addAnnotation(s660Label); plot.addAnnotation(s660Time); plot.addAnnotation(s1000Marker); plot.addAnnotation(s1000Label); plot.addAnnotation(s1000Time); plot.addAnnotation(s1320Marker); plot.addAnnotation(s1320Label); plot.addAnnotation(s1320Time); plot.addAnnotation(carText); plot.addAnnotation(zTo60Marker); plot.addAnnotation(zTo60Label); plot.addAnnotation(zTo60Time); }
From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java
private void setSongsChart() { DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedSongs(10)); JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("SONG_MOST_PLAYED"), null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false); chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11)); chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR)); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); NumberAxis axis = new NumberAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10)); chart.getCategoryPlot().setRangeAxis(axis); chart.getCategoryPlot().setForegroundAlpha(0.6f); chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN); ((StatsDialog) frameControlled).getSongsChart().setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:net.pms.newgui.LooksFrame.java
/** * Constructs a <code>DemoFrame</code>, configures the UI, * and builds the content./*from w w w . j a v a2 s .c o m*/ */ public LooksFrame(AutoUpdater autoUpdater, @Nonnull PmsConfiguration configuration, @Nonnull WindowPropertiesConfiguration windowConfiguration) { super(windowConfiguration.getGraphicsConfiguration()); if (configuration == null) { throw new IllegalArgumentException("configuration can't be null"); } setResizable(true); windowProperties = new WindowProperties(this, STANDARD_SIZE, MINIMUM_SIZE, windowConfiguration); this.autoUpdater = autoUpdater; this.configuration = configuration; assert this.configuration != null; setMinimumSize(MINIMUM_SIZE); Options.setDefaultIconSize(new Dimension(18, 18)); Options.setUseNarrowButtons(true); // Set view level, can be omitted if ViewLevel is implemented in configuration // by setting the view level as variable initialization if (configuration.isHideAdvancedOptions()) { viewLevel = ViewLevel.NORMAL; } else { viewLevel = ViewLevel.ADVANCED; } // Global options Options.setTabIconsEnabled(true); UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, null); // Swing Settings initializeLookAndFeel(); // wait till the look and feel has been initialized before (possibly) displaying the update notification dialog if (autoUpdater != null) { autoUpdater.addObserver(this); autoUpdater.pollServer(); } // Shared Fonts final Integer twelve = Integer.valueOf(12); final Integer fontPlain = Integer.valueOf(Font.PLAIN); final Integer fontBold = Integer.valueOf(Font.BOLD); LazyValue dialogPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.DIALOG, fontPlain, twelve); } }; LazyValue sansSerifPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.SANS_SERIF, fontPlain, twelve); } }; LazyValue monospacedPlain12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.MONOSPACED, fontPlain, twelve); } }; LazyValue dialogBold12 = new LazyValue() { @Override public Object createValue(UIDefaults t) { return new FontUIResource(Font.DIALOG, fontBold, twelve); } }; Object MenuFont = dialogPlain12; Object FixedControlFont = monospacedPlain12; Object ControlFont = dialogPlain12; Object MessageFont = dialogPlain12; Object WindowFont = dialogBold12; Object ToolTipFont = sansSerifPlain12; Object IconFont = ControlFont; // Override our fonts with a unicode font for languages with special characters final String language = configuration.getLanguageTag(); if (language != null && (language.equals("ja") || language.startsWith("zh") || language.equals("ko"))) { // http://propedit.sourceforge.jp/propertieseditor.jnlp MenuFont = sansSerifPlain12; FixedControlFont = sansSerifPlain12; ControlFont = sansSerifPlain12; MessageFont = sansSerifPlain12; WindowFont = sansSerifPlain12; IconFont = sansSerifPlain12; } UIManager.put("Button.font", ControlFont); UIManager.put("CheckBox.font", ControlFont); UIManager.put("CheckBoxMenuItem.font", MenuFont); UIManager.put("ComboBox.font", ControlFont); UIManager.put("EditorPane.font", ControlFont); UIManager.put("FileChooser.listFont", IconFont); UIManager.put("FormattedTextField.font", ControlFont); UIManager.put("InternalFrame.titleFont", WindowFont); UIManager.put("Label.font", ControlFont); UIManager.put("List.font", ControlFont); UIManager.put("PopupMenu.font", MenuFont); UIManager.put("Menu.font", MenuFont); UIManager.put("MenuBar.font", MenuFont); UIManager.put("MenuItem.font", MenuFont); UIManager.put("MenuItem.acceleratorFont", MenuFont); UIManager.put("RadioButton.font", ControlFont); UIManager.put("RadioButtonMenuItem.font", MenuFont); UIManager.put("OptionPane.font", MessageFont); UIManager.put("OptionPane.messageFont", MessageFont); UIManager.put("OptionPane.buttonFont", MessageFont); UIManager.put("Panel.font", ControlFont); UIManager.put("PasswordField.font", ControlFont); UIManager.put("ProgressBar.font", ControlFont); UIManager.put("ScrollPane.font", ControlFont); UIManager.put("Slider.font", ControlFont); UIManager.put("Spinner.font", ControlFont); UIManager.put("TabbedPane.font", ControlFont); UIManager.put("Table.font", ControlFont); UIManager.put("TableHeader.font", ControlFont); UIManager.put("TextArea.font", FixedControlFont); UIManager.put("TextField.font", ControlFont); UIManager.put("TextPane.font", ControlFont); UIManager.put("TitledBorder.font", ControlFont); UIManager.put("ToggleButton.font", ControlFont); UIManager.put("ToolBar.font", MenuFont); UIManager.put("ToolTip.font", ToolTipFont); UIManager.put("Tree.font", ControlFont); UIManager.put("Viewport.font", ControlFont); setTitle("Test"); setIconImage(readImageIcon("icon-32.png").getImage()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JComponent jp = buildContent(); String showScrollbars = System.getProperty("scrollbars", "").toLowerCase(); /** * Handle scrollbars: * * 1) forced scrollbars (-Dscrollbars=true): always display them * 2) optional scrollbars (-Dscrollbars=optional): display them as needed * 3) otherwise (default): don't display them */ switch (showScrollbars) { case "true": setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)); break; case "optional": setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED)); break; default: setContentPane(jp); break; } String projectName = PropertiesUtil.getProjectProperties().get("project.name"); String projectVersion = PropertiesUtil.getProjectProperties().get("project.version"); String title = projectName + " " + projectVersion; // If the version contains a "-" (e.g. "1.50.1-SNAPSHOT" or "1.50.1-beta1"), add a warning message if (projectVersion.indexOf('-') > -1) { title = title + " - " + Messages.getString("LooksFrame.26"); } if (PMS.getTraceMode() == 2) { // Forced trace mode title = title + " [" + Messages.getString("TracesTab.10").toUpperCase() + "]"; } setTitle(title); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // Display tooltips immediately and for a long time ToolTipManager.sharedInstance().setInitialDelay(400); ToolTipManager.sharedInstance().setDismissDelay(60000); ToolTipManager.sharedInstance().setReshowDelay(400); if (!configuration.isMinimized() && System.getProperty(START_SERVICE) == null) { setVisible(true); } BasicSystemUtils.INSTANCE.addSystemTray(this); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java
/** * Initialises the interface of the results panel. *//* w ww . j av a 2s.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); btnMaximize = new JButton("Fullscreen"); btnMaximize.setBounds(10, 475, 124, 23); btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnMaximize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { JFrame chartFrame = new JFrame(); OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JPanel chartPanel = createDistributionPanel(title, statistics, roomType, false, true, 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); chartFrame.setResizable(true); chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); chartFrame.setVisible(true); } } } }); add(btnMaximize); 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; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); OMCampaign[] campaigns = simulation.getCampaigns(); File csvFile = new File(csvPath); try { FileWriter logWriter = new FileWriter(csvFile); BufferedWriter csvOutput = new BufferedWriter(logWriter); OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); String head = ""; switch (statisticsType) { case RoomArithmeticMeans: head = "R_AM"; break; case RoomGeometricMeans: head = "R_GM"; break; case RoomMedianQ50: head = "R_MED"; break; case RoomMaxima: head = "R_MAX"; break; case CellarArithmeticMeans: head = "C_AM"; break; case CellarGeometricMeans: head = "C_GM"; break; case CellarMedianQ50: head = "C_MED"; break; case CellarMaxima: head = "C_MAX"; break; default: head = "R_AM"; break; } csvOutput.write("\"ID\";\"CAMPAIGN\";\"START\";\"" + head + "\""); csvOutput.newLine(); int value = 0; for (int i = 0; i < campaigns.length; i++) { switch (statisticsType) { case RoomArithmeticMeans: value = (int) campaigns[i].getRoomAverage(); break; case RoomGeometricMeans: value = (int) campaigns[i].getRoomLogAverage(); break; case RoomMedianQ50: value = (int) campaigns[i].getRoomMedian(); break; case RoomMaxima: value = (int) campaigns[i].getRoomMaximum(); break; case CellarArithmeticMeans: value = (int) campaigns[i].getCellarAverage(); break; case CellarGeometricMeans: value = (int) campaigns[i].getCellarLogAverage(); break; case CellarMedianQ50: value = (int) campaigns[i].getCellarMedian(); break; case CellarMaxima: value = (int) campaigns[i].getCellarMaximum(); break; default: value = (int) campaigns[i].getRoomAverage(); break; } csvOutput.write("\"" + i + "\";\"" + campaigns[i].getVariation() + "\";\"" + campaigns[i].getStart() + "\";\"" + value + "\""); 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; OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); String title = simulation.toString(); DescriptiveStatistics statistics = null; OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem(); OMRoomType roomType = null; switch (statisticsType) { case RoomArithmeticMeans: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomGeometricMeans: title = "R_GM, " + title; statistics = simulation.getRoomGmDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMedianQ50: title = "R_MED, " + title; statistics = simulation.getRoomMedDescriptiveStats(); roomType = OMRoomType.Room; break; case RoomMaxima: title = "R_MAX, " + title; statistics = simulation.getRoomMaxDescriptiveStats(); roomType = OMRoomType.Room; break; case CellarArithmeticMeans: title = "C_AM, " + title; statistics = simulation.getCellarAmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarGeometricMeans: title = "C_GM, " + title; statistics = simulation.getCellarGmDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMedianQ50: title = "C_MED, " + title; statistics = simulation.getCellarMedDescriptiveStats(); roomType = OMRoomType.Cellar; break; case CellarMaxima: title = "C_MAX, " + title; statistics = simulation.getCellarMaxDescriptiveStats(); roomType = OMRoomType.Cellar; break; default: title = "R_AM, " + title; statistics = simulation.getRoomAmDescriptiveStats(); roomType = OMRoomType.Misc; break; } JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, 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); lblSelectSimulation = new JLabel("Select Simulation"); lblSelectSimulation.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectSimulation.setBounds(10, 65, 132, 14); add(lblSelectSimulation); lblSelectStatistics = new JLabel("Select Statistics"); lblSelectStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectStatistics.setBounds(10, 94, 132, 14); add(lblSelectStatistics); comboBoxSimulations = new JComboBox<OMSimulation>(); comboBoxSimulations.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxSimulations.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { boolean b = false; if (comboBoxSimulations.isEnabled()) { if (comboBoxSimulations.getSelectedItem() != null) { b = true; comboBoxStatistics.removeAllItems(); comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values())); comboBoxStatistics.setSelectedIndex(0); } else { b = false; comboBoxStatistics.removeAllItems(); } } else { b = false; comboBoxStatistics.removeAllItems(); } progressBar.setEnabled(b); btnPdf.setVisible(b); btnCsv.setVisible(b); btnMaximize.setVisible(b); lblExportChartTo.setVisible(b); comboBoxStatistics.setEnabled(b); lblSelectStatistics.setEnabled(b); } }); comboBoxSimulations.setBounds(152, 61, 454, 22); add(comboBoxSimulations); btnRefresh = new JButton("Load"); btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11)); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("") && !txtOmsFile.getText().equals(" ")) { txtOmsFile.setBackground(Color.WHITE); String omsPath = txtOmsFile.getText(); String oms; String[] tmpFileName = omsPath.split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(omsPath + oms); setOmsFile(omsPath + oms); File omsFile = new File(omsPath + oms); if (omsFile.exists()) { txtOmsFile.setBackground(Color.WHITE); btnRefresh.setEnabled(false); comboBoxSimulations.setEnabled(false); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); progressBar.setStringPainted(true); progressBar.setVisible(true); progressBar.setIndeterminate(true); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); refreshSimulationsTask = new RefreshSimulations(); refreshSimulationsTask.execute(); } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "OMS-file not found, please check the file path!", "Error", JOptionPane.ERROR_MESSAGE); } } else { txtOmsFile.setBackground(new Color(255, 222, 222, 128)); JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning", JOptionPane.WARNING_MESSAGE); } } }); comboBoxStatistics = new JComboBox<OMStatistics>(); comboBoxStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11)); comboBoxStatistics.setBounds(152, 90, 454, 22); comboBoxStatistics.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { updateDistribution(); } }); add(comboBoxStatistics); btnRefresh.setBounds(616, 61, 124, 23); add(btnRefresh); panelDistribution = new JPanel(); panelDistribution.setBounds(10, 118, 730, 347); add(panelDistribution); progressBar = new JProgressBar(); progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11)); progressBar.setBounds(10, 475, 730, 23); add(progressBar); progressBar.setEnabled(false); comboBoxStatistics.setEnabled(false); lblSelectStatistics.setEnabled(false); btnPdf.setVisible(false); btnCsv.setVisible(false); btnMaximize.setVisible(false); lblExportChartTo.setVisible(false); lblHelp = new JLabel("Select an OMS-Simulation file to analyse the simulation results and " + "display the distribution chart."); lblHelp.setForeground(Color.GRAY); lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblHelp.setBounds(10, 10, 730, 14); add(lblHelp); lblSelectOms = new JLabel("Open OMS-File"); lblSelectOms.setFont(new Font("SansSerif", Font.PLAIN, 11)); lblSelectOms.setBounds(10, 36, 132, 14); add(lblSelectOms); txtOmsFile = new JTextField(); txtOmsFile.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { setOmsFile(txtOmsFile.getText()); } }); txtOmsFile.setFont(new Font("SansSerif", Font.PLAIN, 11)); txtOmsFile.setColumns(10); txtOmsFile.setBounds(152, 33, 454, 20); add(txtOmsFile); buttonBrowse = new JButton("Browse"); buttonBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFileChooser fileDialog = new JFileChooser(); fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms")); fileDialog.showOpenDialog(getParent()); final File file = fileDialog.getSelectedFile(); if (file != null) { String oms; String[] tmpFileName = file.getAbsolutePath().split("\\."); if (tmpFileName[tmpFileName.length - 1].equals("oms")) { oms = ""; } else { oms = ".oms"; } txtOmsFile.setText(file.getAbsolutePath() + oms); setOmsFile(file.getAbsolutePath() + oms); } } }); buttonBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11)); buttonBrowse.setBounds(616, 32, 124, 23); add(buttonBrowse); progressBar.setVisible(false); }
From source file:knop.psfj.heatmap.HeatMapGenerator.java
/** * Gets the colored heat map with scale. * * @param width the width/* www. ja v a 2 s .co m*/ * @return the colored heat map with scale */ public ImageProcessor getColoredHeatMapWithScale(int width) { int fontSize = width / 20; java.awt.Font font = new java.awt.Font(java.awt.Font.SANS_SERIF, java.awt.Font.PLAIN, fontSize); int headerSize = fontSize; int margin = width / 30; // getting the colored heatmap ImageProcessor ip = getColoredHeatMap(width); // getting min and max values for the lut double min = getMin(); double max = getMax(); ImageProcessor lut = getLutImage(ip.getHeight(), margin, (float) min, (float) max); ip.setFont(font); // setting some coordinnates int heatmapX = margin; int heatmapY = margin; int lutX = ip.getWidth() + margin * 2; int lutY = heatmapY; int scaleHeight = ip.getHeight() / 30; int finalWidth = heatmapY + margin * 2 + ip.getWidth() + lut.getWidth() + ip.getStringWidth("1000000 nm"); int finalHeight = margin * 2 + fontSize + ip.getHeight() + scaleHeight; ImageProcessor finalIp = new ColorProcessor(finalWidth, finalHeight); finalIp.setColor(Color.white); finalIp.fill(); // drawing heatmap finalIp.copyBits(ip, heatmapX, heatmapY, Blitter.COPY); // drawing lut finalIp.copyBits(lut, lutX, lutY, Blitter.COPY); // drawing lut scale finalIp.setFont(font); int lutScaleX = lutX + lut.getWidth(); int lutScaleThikness = width / 100; int lutScaleLength = margin; int leftScaleStep = MathUtils.round(lut.getHeight() / scaleDivision); finalIp.setColor(Color.black); for (int i = 0; i != scaleDivision + 1; i++) { int leftScaleY = lutY + leftScaleStep * i - (lutScaleThikness * i / (scaleDivision)); // finalIp.drawRect(leftScaleX, lutY+leftScaleStep*i, leftScaleLength, // leftScaleThikness); finalIp.fill(new Roi(new Rectangle(lutScaleX, leftScaleY, lutScaleLength, lutScaleThikness))); finalIp.drawString( MathUtils.formatDouble( getMin() + ((getMax() - getMin()) * (scaleDivision - i) / (scaleDivision)), getUnit()), lutScaleX + margin * 2, leftScaleY + finalIp.getFont().getSize() / 2); } // drawing heatmap scale int scaleX = margin * 2; int scaleY = ip.getHeight() - margin; //int scaleMeasureInUm = roundUp(MathUtils.round(1.0*getColumnCount()*stepSize/5)); ///int scaleMeasureInPixel = MathUtils.round(scaleMeasureInUm/stepSize); drawScale(finalIp, width, scaleX, scaleY, scaleHeight, margin); return finalIp; }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * /*from w ww . j a v a 2 s .com*/ */ private void synonymCleanup() { JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); String text = ""; try { String template = "synonym_cleanup_%s.html"; String fileName = String.format(template, Locale.getDefault().getLanguage()); File file = XMLHelper.getConfigDir(fileName); if (!file.exists()) { fileName = String.format(template, "en"); file = XMLHelper.getConfigDir(fileName); } text = FileUtils.readFileToString(file); } catch (Exception ex) { ex.printStackTrace(); } JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); p.add(js, BorderLayout.CENTER); tp.setContentType("text/html"); tp.setText(text); tp.setCaretPosition(0); tp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 18)); CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), getI18nRS("SYN_CLEANUP"), true, CustomDialog.OKCANCELAPPLY, p); dlg.setOkLabel(getI18nRS("SYN_CLEANUP")); dlg.setCancelLabel(getI18nRS("Report")); dlg.setApplyLabel(getResourceString("CANCEL")); dlg.setCloseOnApplyClk(true); dlg.createUI(); dlg.setSize(600, 450); UIHelper.centerAndShow(dlg); if (dlg.getBtnPressed() == CustomDialog.OK_BTN || dlg.getBtnPressed() == CustomDialog.CANCEL_BTN) { boolean doCleanup = dlg.getBtnPressed() == CustomDialog.OK_BTN; SynonymCleanup synonymCleanup = new SynonymCleanup(doCleanup); synonymCleanup.execute(); // start the background task } }