List of usage examples for java.awt Dimension getHeight
public double getHeight()
From source file:com.clough.android.adbv.view.MainFrame.java
public MainFrame() { initComponents();// ww w .j a v a 2s .c o m setIconImage(ValueHolder.Icons.APPLICATION.getImage()); setExtendedState(JFrame.MAXIMIZED_BOTH); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); double windowWidth = screenDimension.getWidth(); double windowHeight = screenDimension.getHeight(); int frameWidth = (int) (windowWidth * (3d / 4d)); int frameHeight = (int) (windowHeight * (3d / 4d)); setMinimumSize(new Dimension(frameWidth, frameHeight)); setLocation((int) ((windowWidth - frameWidth) / 2d), (int) ((windowHeight - frameHeight) / 2d)); int deviderSize = (int) (frameWidth * (1d / 100d)); int deviderLocationForSpliter0 = (int) (frameWidth / 5d); splitPane0.setDividerLocation(deviderLocationForSpliter0); int deviderLocationForSpliter1 = (int) (frameWidth * (6d / 7d)); splitPane1.setDividerLocation(deviderLocationForSpliter1); int subDeviderLocation = (int) (frameHeight / 6d); splitPane2.setDividerLocation(subDeviderLocation); queryHistoryContainerPanel.setMinimumSize(new Dimension(deviderLocationForSpliter0, 0)); queryRootConatinerPanel.setMinimumSize(new Dimension(0, subDeviderLocation)); queryingTextArea.requestFocus(); resultTable.setModel(new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return false; } }); defaultTableModel = (DefaultTableModel) resultTable.getModel(); resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); tableColumnAdjuster = new TableColumnAdjuster(resultTable); historyContainingPanel.setLayout(new GridLayout(0, 1)); }
From source file:org.rdv.viz.chart.ChartViz.java
/** * Takes the chart and puts it on the clipboard as an image. */// w ww .j a v a 2 s.c o m private void copyChart() { // get the system clipboard Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // create an image of the chart with the preferred dimensions Dimension preferredDimension = chartPanel.getPreferredSize(); Image image = chart.createBufferedImage((int) preferredDimension.getWidth(), (int) preferredDimension.getHeight()); // wrap image in the transferable and put on the clipboard ImageSelection contents = new ImageSelection(image); clipboard.setContents(contents, null); }
From source file:brainflow.app.toplevel.BrainFlow.java
private void initializeWorkspace() throws Exception { StopWatch watch = new StopWatch(); watch.start("laying out workspace"); log.info("initializing workspace"); //_frame.getDockableBarManager().getMainContainer().setLayout(new BorderLayout()); //_frame.getDockableBarManager().getMainContainer().add(_tabbedPane, BorderLayout.CENTER); //brainFrame.getMainPanel().add(documentPane, BorderLayout.CENTER); brainFrame.getDockingManager().getWorkspace().setLayout(new BorderLayout()); brainFrame.getDockingManager().getWorkspace().add(documentPane, BorderLayout.CENTER); brainFrame.getDockingManager().beginLoadLayoutData(); brainFrame.getDockingManager().setInitSplitPriority(DefaultDockingManager.SPLIT_EAST_WEST_SOUTH_NORTH); JComponent canvas = DisplayManager.get().getSelectedCanvas().getComponent(); canvas.setRequestFocusEnabled(true); canvas.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); watch.stopAndReport("laying out workspace"); watch.start("opening document"); documentPane.setTabPlacement(DocumentPane.BOTTOM); documentPane.openDocument(createCanvasDocument(DisplayManager.get().getSelectedCanvas(), "Canvas-1")); documentPane.setActiveDocument("Canvas-1"); watch.stopAndReport("opening document"); log.info("initializing loading dock"); watch.start("init loading dock"); initLoadingDock();//from ww w . ja va2 s. c om watch.stopAndReport("init loading dock"); log.info("initializing project view"); watch.start("init project view"); initProjectView(); watch.stopAndReport("init project view"); log.info("initializing image table view"); watch.start("init ploadable image table view"); initLoadableImageTableView(); watch.stopAndReport("init ploadable image table view"); log.info("initializing control panel"); watch.start("init control panel"); initControlPanel(); initCoordinatePanel(); watch.stopAndReport("init control panel"); log.info("initializing event monitor"); watch.start("event bus monitor"); initEventBusMonitor(); log.info("initializing log monitor"); watch.stopAndReport("event bus monitor"); watch.start("log monitor"); initLogMonitor(); watch.stopAndReport("log monitor"); watch.start("layout docks"); brainFrame.getDockableBarManager().loadLayoutData(); // brainFrame.toFront(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); brainFrame.setSize((int) screenSize.getWidth(), (int) screenSize.getHeight() - 50); watch.stopAndReport("layout docks"); watch.start("canvas bar"); CanvasBar cbar = new CanvasBar(); canvas.add(cbar.getComponent(), BorderLayout.NORTH); watch.stopAndReport("canvas bar"); brainFrame.getDockingManager().loadLayoutData(); }
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * Paints the component by drawing the chart to fill the entire component, * but allowing for the insets (which will be non-zero if a border has been * set for this component). To increase performance (at the expense of * memory), an off-screen buffer image can be used. * * @param g the graphics device for drawing on. *///ww w . ja v a 2 s.c om public void paintComponent(Graphics g) { super.paintComponent(g); if (this.chart == null) { return; } Graphics2D g2 = (Graphics2D) g.create(); // first determine the size of the chart rendering area... Dimension size = getSize(); Insets insets = getInsets(); Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); // work out if scaling is required... boolean scale = false; double drawWidth = available.getWidth(); double drawHeight = available.getHeight(); this.scaleX = 1.0; this.scaleY = 1.0; if (drawWidth < this.minimumDrawWidth) { this.scaleX = drawWidth / this.minimumDrawWidth; drawWidth = this.minimumDrawWidth; scale = true; } else if (drawWidth > this.maximumDrawWidth) { this.scaleX = drawWidth / this.maximumDrawWidth; drawWidth = this.maximumDrawWidth; scale = true; } if (drawHeight < this.minimumDrawHeight) { this.scaleY = drawHeight / this.minimumDrawHeight; drawHeight = this.minimumDrawHeight; scale = true; } else if (drawHeight > this.maximumDrawHeight) { this.scaleY = drawHeight / this.maximumDrawHeight; drawHeight = this.maximumDrawHeight; scale = true; } Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight); // are we using the chart buffer? if (this.useBuffer) { // if buffer is being refreshed, it needs clearing unless it is // new - use the following flag to track this... boolean clearBuffer = true; // do we need to resize the buffer? if ((this.chartBuffer == null) || (this.chartBufferWidth != available.getWidth()) || (this.chartBufferHeight != available.getHeight())) { this.chartBufferWidth = (int) available.getWidth(); this.chartBufferHeight = (int) available.getHeight(); this.chartBuffer = createImage(this.chartBufferWidth, this.chartBufferHeight); // GraphicsConfiguration gc = g2.getDeviceConfiguration(); // this.chartBuffer = gc.createCompatibleImage( // this.chartBufferWidth, this.chartBufferHeight, // Transparency.TRANSLUCENT); this.refreshBuffer = true; clearBuffer = false; // buffer is new, no clearing required } // do we need to redraw the buffer? if (this.refreshBuffer) { this.refreshBuffer = false; // clear the flag Rectangle2D bufferArea = new Rectangle2D.Double(0, 0, this.chartBufferWidth, this.chartBufferHeight); Graphics2D bufferG2 = (Graphics2D) this.chartBuffer.getGraphics(); if (clearBuffer) { bufferG2.clearRect(0, 0, this.chartBufferWidth, this.chartBufferHeight); } if (scale) { AffineTransform saved = bufferG2.getTransform(); AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY); bufferG2.transform(st); this.chart.draw(bufferG2, chartArea, this.anchor, this.info); bufferG2.setTransform(saved); } else { this.chart.draw(bufferG2, bufferArea, this.anchor, this.info); } } g2.drawImage(this.chartBuffer, insets.left, insets.top, this); g2.draw((Shape) activeROI.getShapesList().get(1)); // Dibujar las rois que se encuentren activas } // or redrawing the chart every time... else { AffineTransform saved = g2.getTransform(); g2.translate(insets.left, insets.top); if (scale) { AffineTransform st = AffineTransform.getScaleInstance(this.scaleX, this.scaleY); g2.transform(st); } this.chart.draw(g2, chartArea, this.anchor, this.info); g2.drawImage(this.chartBuffer, insets.left, insets.top, this); // Se pintan las Roi activa drawsROIs(g2); g2.setTransform(saved); } g2.dispose(); this.anchor = null; }
From source file:org.jajuk.ui.views.CoverView.java
@Override public void componentResized(final ComponentEvent e) { Dimension dim = getSize(); if (dim.getHeight() <= 0 || dim.getWidth() <= 0) { return;/*from w ww . ja va2s.com*/ } final long lCurrentDate = System.currentTimeMillis(); // adjusting code if (lCurrentDate - lDateLastResize < 500) { // Do consider only one event every // 500 ms to avoid race conditions and lead to unexpected states (verified) return; } lDateLastResize = lCurrentDate; Log.debug("Cover resized, view=" + getID() + " size=" + getSize()); // Run this in another thread to accelerate the component resize events processing and filter by time new Thread() { @Override public void run() { if (fileReference == null) { // regular cover view if (QueueModel.isStopped()) { update(new JajukEvent(JajukEvents.ZERO)); } // check if a track has already been launched else if (QueueModel.isPlayingRadio()) { update(new JajukEvent(JajukEvents.WEBRADIO_LAUNCHED, ObservationManager.getDetailsLastOccurence(JajukEvents.WEBRADIO_LAUNCHED))); // If the view is displayed for the first time, a ComponentResized event is launched at its first display but // we want to perform the full process : update past launches files (FILE_LAUNCHED). // But if it is no more the initial resize event, we only want to refresh the cover, not the full story. } else if (!initEvent) { displayCurrentCover(); } else { update(new JajukEvent(JajukEvents.FILE_LAUNCHED)); } } else { // cover view used as dialog update(new JajukEvent(JajukEvents.COVER_NEED_REFRESH)); } // It will never more be the first time ... CoverView.this.initEvent = false; } }.start(); }
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
/** * adjusts the viewable are of the log (zoom) *//*from w w w . ja va2s .c o m*/ public void setViewportZoomIn() { Dimension d = dca.getViewportSize(); int width = Math.abs(p1.x - p2.x); int height = Math.abs(p1.y - p2.y); int value = (int) (Math.log10(this.getWidth() * (d.getWidth() / width) / dca.getViewportSize().getWidth()) * 1000.0); if (value > 3000) return; value = (int) (Math.log10(this.getHeight() * (d.getHeight() / height) / dca.getViewportSize().getHeight()) * 1000.0); if (value > 3000) return; updWidth = (int) (this.getWidth() * (d.getWidth() / width)); updHight = (int) (this.getHeight() * (d.getHeight() / height)); Dimension dim = new Dimension(updWidth, updHight); int pos_x = Math.min(p1.x, p2.x); int pos_y = Math.min(p1.y, p2.y); Point p = new Point((int) (pos_x * d.getWidth() / width), (int) (pos_y * d.getHeight() / height)); this.setPreferredSize(dim); coUtil.updateMilli2pixelsRatio(this.getWidth(), BORDER); this.revalidate(); dca.setScrollBarPosition(p); p1 = null; p2 = null; adjustSlideBar(); }
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
/** * adjusts the viewable are of the log (zoom) *//* ww w . j a v a2s .co m*/ public Point zoomInViewPort() { if (p1 == null || p2 == null) return null; Dimension d = dca.getViewportSize(); int width = Math.abs(p1.x - p2.x); int height = Math.abs(p1.y - p2.y); int value = (int) (Math.log10(this.getWidth() * (d.getWidth() / width) / dca.getViewportSize().getWidth()) * 1000.0); if (value > 3000) return null; value = (int) (Math.log10(this.getHeight() * (d.getHeight() / height) / dca.getViewportSize().getHeight()) * 1000.0); if (value > 3000) return null; updWidth = (int) (this.getWidth() * (d.getWidth() / width)); updHight = (int) (this.getHeight() * (d.getHeight() / height)); Dimension dim = new Dimension(updWidth, updHight); int pos_x = Math.min(p1.x, p2.x); int pos_y = Math.min(p1.y, p2.y); this.setPreferredSize(dim); coUtil.updateMilli2pixelsRatio(this.getWidth(), BORDER); this.revalidate(); p1 = null; p2 = null; adjustSlideBar(); return new Point((int) (pos_x * d.getWidth() / width), (int) (pos_y * d.getHeight() / height)); }
From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java
/** * Initialises the interface of the results panel. *//* w w w .ja va 2 s. co 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:com.aspose.showcase.qrcodegen.web.api.controller.QRCodeManagementController.java
/** * generateQRCode - Main API to generate QR Code * /* www . j a va 2 s .c om*/ * @throws Exception * * */ @RequestMapping(value = "generate", method = RequestMethod.GET, produces = { MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_GIF_VALUE, MEDIATYPE_IMAGE_TIFF_VALUE, MEDIATYPE_IMAGE_BMP_VALUE }) @ApiOperation(value = "Generate QR Code.") public ResponseEntity<byte[]> generateQRCode( @ApiParam(value = "data", name = "data", required = true) @RequestParam("data") String data, @ApiParam(value = "A user-chosen password that can be used with password-based encryption (PBE) Algo PBEWITHMD5AND128BITAES-CBC-OPENSSL)", name = "passKey", required = false) @RequestParam(required = false, value = "passKey") String passKey, @ApiParam(value = "ForeColor e.g #000000 (Black - RGB(hex))", name = "foreColor", required = false) @RequestParam(required = false, value = "foreColor") String foreColor, @ApiParam(value = "BackgroundColor e.g #FFFFFF (White - RGB(hex))", name = "bgColor", required = false) @RequestParam(required = false, value = "bgColor") String bgColor, @ApiParam(value = "L|M|Q|H - Reed-Solomon error correctionCode Level(from low to high) default=Low", name = "ecc", required = false) @RequestParam(required = false, value = "ecc") String ecc, @ApiParam(value = "Image Size e.g #150x150", name = "size", required = false) @RequestParam(required = false, value = "size") String size, @ApiParam(value = "jpeg|tiff|gif|png|bmp - default=png", name = "format", required = false) @RequestParam(required = false, value = "format") String format, @ApiParam(value = "true|false default=false", name = "download", required = false) @RequestParam(required = false, value = "download") boolean download, @ApiIgnore @Value("#{request.getHeader('" + ACCEPT_HEADER + "')}") String acceptHeaderValue) throws Exception { Assert.isTrue(StringUtils.isNotEmpty(data), "Please provide valid data param."); LOGGER.debug("Accept Header::" + acceptHeaderValue); HttpHeaders responseHeaders = new HttpHeaders(); if (!(StringUtils.isBlank(passKey))) { builder.setCodeText(StringEncryptor.encrypt(data, passKey)); } else { builder.setCodeText(data); } builder.setImageQuality(ImageQualityMode.Default); builder.setSymbologyType(Symbology.QR); builder.setCodeLocation(CodeLocation.None); builder.setForeColor(getColorValue(foreColor, "#000000")); builder.setBackColor(getColorValue(bgColor, "#FFFFFF")); builder.setQRErrorLevel(getErrorCorrectCode(ecc, QRErrorLevel.LevelL)); Dimension imageDimention = geCustomImageSizeDimention(size); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageFormatDTO responseImageTypeDto = getRequestedImageFormat(responseHeaders, acceptHeaderValue, format); long startTime = System.currentTimeMillis(); LOGGER.debug("builder.save Start @ " + startTime); byte[] imageInByte; if (imageDimention != null) { // Set graphics unit builder.setGraphicsUnit(GraphicsUnit.Millimeter); // Set margins builder.getMargins().set(0); builder.setForeColor(getColorValue(foreColor, "#000000")); builder.setBackColor(getColorValue(bgColor, "#FFFFFF")); LOGGER.debug("builder.getGraphicsUnit() ::" + builder.getGraphicsUnit()); // Get BufferedImage with exact bar code only BufferedImage img = builder.getOnlyBarCodeImage(); LOGGER.debug("img.getWidth() : :" + img.getWidth()); LOGGER.debug("img.getHeight() :: " + img.getHeight()); if (imageDimention.getWidth() < img.getWidth()) { imageDimention.width = img.getWidth(); } if (imageDimention.getHeight() < img.getHeight()) { imageDimention.height = img.getHeight(); } BufferedImage img2 = builder.getCustomSizeBarCodeImage(imageDimention, true); MediaType responseType = responseImageTypeDto.getMediaType(); ImageIO.write(img2, responseType.getSubtype(), baos); baos.flush(); imageInByte = baos.toByteArray(); baos.close(); } else { builder.setxDimension(1.0f); builder.setyDimension(1.0f); builder.save(baos, responseImageTypeDto.getBarCodeImageFormat()); baos.flush(); imageInByte = baos.toByteArray(); baos.close(); } long endTime = System.currentTimeMillis(); LOGGER.debug("builder.save took " + (endTime - startTime) + " milliseconds"); if (download) { MediaType responseType = responseImageTypeDto.getMediaType(); responseHeaders.setContentType(responseType); responseHeaders.add("Content-Disposition", "attachment; filename=" + "Aspose_BarCode_QRCodeGen." + responseType.getSubtype()); } return new ResponseEntity<byte[]>(imageInByte, responseHeaders, HttpStatus.CREATED); }
From source file:org.fhcrc.cpl.viewer.gui.ProteinMatcherFrame.java
/** * initial setup of UI and class variables */// w ww. j a v a 2s .c o m public void initialize() { _ms1Features = getMS1Features(); if (_ms1Features == null) { ApplicationContext.infoMessage(TextProvider.getText("AMT_REQUIRES_DISPLAYED_FEATURES")); this.setVisible(false); this.dispose(); return; } this.setVisible(true); //graphical stuff try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/gui/ProteinMatcherMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } Container contentPanel; try { contentPanel = Localizer.renderSwixml("org/fhcrc/cpl/viewer/gui/ProteinMatcherFrame.xml", this); setContentPane(contentPanel); pack(); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_CREATING_DIALOG"), x); throw new RuntimeException(x); } Dimension d = contentPanel.getPreferredSize(); setBounds(600, 100, (int) d.getWidth(), (int) d.getHeight()); ListenerHelper helper = new ListenerHelper(this); helper.addListener(tblProteins.getSelectionModel(), "tblProteinsModel_valueChanged"); helper.addListener(buttonFilterProteins, "buttonFilterProteins_actionPerformed"); //hitting enter in the text field should act the same as hitting the filter button. Hack, focus, whatever helper.addListener(textProteinPrefix, "buttonFilterProteins_actionPerformed"); helper.addListener(tblFeatures.getSelectionModel(), "tblFeaturesModel_valueChanged"); _proteinTableModel = new ProteinTableModel(); tblProteins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblProteins.setAutoCreateColumnsFromModel(false); tblProteins.setModel(_proteinTableModel); tblProteins.setColumnModel(_proteinTableModel.columnModel); if (null != displayMatchedUnmatchedComboBox) { //TODO: should really use TextProvider here, and use an internal value for determining state displayMatchedUnmatchedComboBox.addItem("matched"); displayMatchedUnmatchedComboBox.addItem("unmatched peptides"); displayMatchedUnmatchedComboBox.addItem("unmatched ms2"); helper.addListener(displayMatchedUnmatchedComboBox, "displayMatchedUnmatchedComboBox_actionPerformed"); } _featureTableModel = new FeatureTableModel(); tblFeatures.setModel(_featureTableModel); tblFeatures.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); tblFeatures.setAutoCreateColumnsFromModel(false); ProteinTablePopupMenu proteinPopup = new ProteinTablePopupMenu(); tblProteins.setComponentPopupMenu(proteinPopup); proteinLabel.setComponentPopupMenu(proteinPopup); }