List of usage examples for java.awt Frame add
public Component add(Component comp)
From source file:peakmlviewer.dialog.timeseries.EditableChart.java
public EditableChart(Composite parent, int style) { super(parent, SWT.EMBEDDED | style); setLayout(new FillLayout()); // create the components linechart = ChartFactory.createLineChart(null, "", "Intensity", dataset, PlotOrientation.VERTICAL, false, // legend false, // tooltips false // urls );/*from w w w .j av a 2s. com*/ CategoryPlot plot = (CategoryPlot) linechart.getPlot(); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setRange(0, 1); CategoryAxis xaxis = (CategoryAxis) plot.getDomainAxis(); xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesFilled(0, true); renderer.setSeriesShapesVisible(0, true); linechart.setBackgroundPaint(Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // add the components // -------------------------------------------------------------------------------- // This uses the SWT-trick for embedding awt-controls in an SWT-Composit. try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { ; } java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this); // create a few ChartPanel, without the popup-menu (5x false) panel = new ChartPanel(linechart, false, false, false, false, false); panel.addMouseListener(this); panel.addMouseMotionListener(this); panel.setRangeZoomable(false); panel.setDomainZoomable(false); frame.add(panel); // -------------------------------------------------------------------------------- }
From source file:edu.harvard.i2b2.query.QueryC.java
/** * @param args//from w w w. j a va 2 s . co m */ protected Control createContents(Composite parent) { //log.info("Starting Query Mode"); GridLayout topGridLayout = new GridLayout(1, false); topGridLayout.numColumns = 1; topGridLayout.marginWidth = 2; topGridLayout.marginHeight = 2; setLayout(topGridLayout); Composite queryComposite = new Composite(this, SWT.NONE); queryComposite.setLayout(new FillLayout(SWT.VERTICAL)); GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.FILL; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; queryComposite.setLayoutData(gridData2); // the horizontal sash form SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL); horizontalForm.setOrientation(SWT.HORIZONTAL); horizontalForm.setLayout(new GridLayout()); //left sash form SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL); leftVerticalForm.setOrientation(SWT.VERTICAL); leftVerticalForm.setLayout(new GridLayout()); if (bWantStatusLine) { slm.createControl(this, SWT.NULL); } slm.setMessage("i2b2 Explorer Version 2.0"); slm.update(true); // Create the tab folder final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE); // Create each tab and set its text, tool tip text, // image, and control TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE); oTreeTab.setText("Concept trees"); oTreeTab.setToolTipText("Hierarchically organized patient characteristics"); oTreeTab.setControl(getQueryTabControl(oTabFolder)); //TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE); //oFindTab.setText("Find"); //oFindTab.setToolTipText("Free-form find tool for patient characteristics"); //FindTool find = new FindTool(slm); //oFindTab.setControl(find.getFindTabControl(oTabFolder)); // Select the first tab (index is zero-based) oTabFolder.setSelection(0); // Create the tab folder final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE); TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE); previousRunTab.setText("Patient Sets and Previous Queries"); previousRunTab.setToolTipText("Patient Sets & Previous Queries"); final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED); previousRunTab.setControl(composite); /* Create and setting up frame */ Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer_left = runRoot.getContentPane(); //runTreePanel = new QueryPreviousRunsPanel(this, null); //oAwtContainer_left.add(runTreePanel); // Select the first tab (index is zero-based) queryRunFolder.setSelection(0); final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL); verticalForm.setOrientation(SWT.VERTICAL); verticalForm.setLayout(null); Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect); /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(rightComp); Panel panel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); oAwtContainer = root.getContentPane(); if (mode_ == 0) { queryPanel = new QueryPanelInvestigator(this); } else { queryPanel = new QueryPanel(this); } oAwtContainer.add(queryPanel); queryPanel.setSplitBounds(oAwtContainer.getBounds()); if (mode_ == 0) { //bottomC = new ExplorerC(verticalForm, false); verticalForm.setWeights(new int[] { 40, 50 }); } verticalForm.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { if (mode_ == 0) { int height = verticalForm.getBounds().height; //System.out.println("Height: "+height); if (height > 285) { try { verticalForm.setWeights(new int[] { 285, height - 285 }); } catch (Exception e) { return; } } } } }); horizontalForm.setWeights(new int[] { 20, 70 }); return parent; }
From source file:edu.harvard.i2b2.query.ui.QueryC.java
/** * @param args/* w ww .j a v a 2 s . c o m*/ */ protected Control createContents(Composite parent) { // log.info("Starting Query Mode"); GridLayout topGridLayout = new GridLayout(1, false); topGridLayout.numColumns = 1; topGridLayout.marginWidth = 2; topGridLayout.marginHeight = 2; setLayout(topGridLayout); Composite queryComposite = new Composite(this, SWT.NONE); queryComposite.setLayout(new FillLayout(SWT.VERTICAL)); GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.FILL; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; queryComposite.setLayoutData(gridData2); // the horizontal sash form SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL); horizontalForm.setOrientation(SWT.HORIZONTAL); horizontalForm.setLayout(new GridLayout()); // left sash form SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL); leftVerticalForm.setOrientation(SWT.VERTICAL); leftVerticalForm.setLayout(new GridLayout()); if (bWantStatusLine) { slm.createControl(this, SWT.NULL); } slm.setMessage("i2b2 Explorer Version 1.6.0"); slm.update(true); // Create the tab folder final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE); // Create each tab and set its text, tool tip text, // image, and control TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE); oTreeTab.setText("Concept trees"); oTreeTab.setToolTipText("Hierarchically organized patient characteristics"); oTreeTab.setControl(getQueryTabControl(oTabFolder)); // TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE); // oFindTab.setText("Find"); // oFindTab.setToolTipText( // "Free-form find tool for patient characteristics"); // FindTool find = new FindTool(slm); // oFindTab.setControl(find.getFindTabControl(oTabFolder)); // Select the first tab (index is zero-based) oTabFolder.setSelection(0); // Create the tab folder final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE); TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE); previousRunTab.setText("Patient Sets and Previous Queries"); previousRunTab.setToolTipText("Patient Sets & Previous Queries"); final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED); previousRunTab.setControl(composite); /* Create and setting up frame */ Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer_left = runRoot.getContentPane(); // runTreePanel = new QueryPreviousRunsPanel(this, null); // oAwtContainer_left.add(runTreePanel); // Select the first tab (index is zero-based) queryRunFolder.setSelection(0); final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL); verticalForm.setOrientation(SWT.VERTICAL); verticalForm.setLayout(null); Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect); /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(rightComp); Panel panel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); oAwtContainer = root.getContentPane(); if (mode_ == 0) { queryToolPanel = new QueryToolInvestigatorPanel(this); } else { queryToolPanel = new QueryToolPanel(this); } oAwtContainer.add(queryToolPanel); queryToolPanel.setSplitBounds(oAwtContainer.getBounds()); if (mode_ == 0) { // bottomC = new ExplorerC(verticalForm, false); verticalForm.setWeights(new int[] { 40, 50 }); } verticalForm.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { if (mode_ == 0) { int height = verticalForm.getBounds().height; // System.out.println("Height: "+height); if (height > 285) { try { verticalForm.setWeights(new int[] { 285, height - 285 }); } catch (Exception e) { return; } } } } }); horizontalForm.setWeights(new int[] { 20, 70 }); return parent; }
From source file:edu.harvard.i2b2.previousquery.QueryC.java
/** * @param args/*w w w .j a v a 2 s .c om*/ */ protected Control createContents(Composite parent) { //log.info("Starting Query Mode"); GridLayout topGridLayout = new GridLayout(1, false); topGridLayout.numColumns = 1; topGridLayout.marginWidth = 2; topGridLayout.marginHeight = 2; setLayout(topGridLayout); Composite queryComposite = new Composite(this, SWT.NONE); queryComposite.setLayout(new FillLayout(SWT.VERTICAL)); GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.FILL; gridData2.grabExcessHorizontalSpace = true; gridData2.grabExcessVerticalSpace = true; queryComposite.setLayoutData(gridData2); // the horizontal sash form SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL); horizontalForm.setOrientation(SWT.HORIZONTAL); horizontalForm.setLayout(new GridLayout()); //left sash form SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL); leftVerticalForm.setOrientation(SWT.VERTICAL); leftVerticalForm.setLayout(new GridLayout()); if (bWantStatusLine) { slm.createControl(this, SWT.NULL); } slm.setMessage("i2b2 Explorer Version 2.0"); slm.update(true); // Create the tab folder final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE); // Create each tab and set its text, tool tip text, // image, and control TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE); oTreeTab.setText("Concept trees"); oTreeTab.setToolTipText("Hierarchically organized patient characteristics"); oTreeTab.setControl(getQueryTabControl(oTabFolder)); TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE); oFindTab.setText("Find"); oFindTab.setToolTipText("Free-form find tool for patient characteristics"); //FindTool find = new FindTool(slm); //oFindTab.setControl(find.getFindTabControl(oTabFolder)); // Select the first tab (index is zero-based) oTabFolder.setSelection(0); // Create the tab folder final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE); TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE); previousRunTab.setText("Patient Sets and Previous Queries"); previousRunTab.setToolTipText("Patient Sets & Previous Queries"); final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED); previousRunTab.setControl(composite); /* Create and setting up frame */ Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer_left = runRoot.getContentPane(); runTreePanel = new QueryPreviousRunsPanel(this);//, null); oAwtContainer_left.add(runTreePanel); // Select the first tab (index is zero-based) queryRunFolder.setSelection(0); final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL); verticalForm.setOrientation(SWT.VERTICAL); verticalForm.setLayout(null); Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect); /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(rightComp); Panel panel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); oAwtContainer = root.getContentPane(); if (mode_ == 0) { //queryPanel = new QueryPanelInvestigator(this); } else { queryPanel = new QueryPanel(this); } oAwtContainer.add(queryPanel); queryPanel.setSplitBounds(oAwtContainer.getBounds()); if (mode_ == 0) { //bottomC = new ExplorerC(verticalForm, false); verticalForm.setWeights(new int[] { 40, 50 }); } verticalForm.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { if (mode_ == 0) { int height = verticalForm.getBounds().height; //System.out.println("Height: "+height); if (height > 285) { try { verticalForm.setWeights(new int[] { 285, height - 285 }); } catch (Exception e) { return; } } } } }); horizontalForm.setWeights(new int[] { 20, 70 }); return parent; }
From source file:gov.redhawk.statistics.ui.views.StatisticsView.java
/** * This is a callback that will allow us to create the viewer and initialize it. *//*w w w. j a va 2 s. c o m*/ @Override public void createPartControl(Composite comp) { parent = comp; parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create()); // Custom Action for the View's Menu CustomAction customAction = new CustomAction() { @Override public void run() { SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars); dialog.create(); if (dialog.open() == Window.OK) { numBars = dialog.getNumBars(); curIndex = dialog.getSelectedIndex(); refreshJob.schedule(); } } }; customAction.setText("Settings"); getViewSite().getActionBars().getMenuManager().add(customAction); // creation of chart composite and selection of associated options Composite chartComposite = new Composite(parent, SWT.EMBEDDED); chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false, true, false); org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground(); chart.setBackgroundPaint( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE); Frame chartFrame = SWT_AWT.new_Frame(chartComposite); chartFrame.setBackground( new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chartFrame.setLayout(new GridLayout()); ChartPanel jFreeChartPanel = new ChartPanel(chart); chartFrame.add(jFreeChartPanel); ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setMargin(0.05); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { @Override public String generateLabel(XYDataset dataset, int series, int item) { return String.valueOf((int) (dataset.getYValue(series, item))); } }); renderer.setBasePaint(new Color(139, 0, 0)); renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() { @Override public String generateLabel(XYDataset ds, int i) { if (ds.getSeriesCount() == 2) { if (i == 0) { return "Real"; } else if (i == 1) { return "Imaginary"; } else { return "Complex"; } } else if (ds.getSeriesCount() > 1) { return "Dimension " + i; } return null; } }); chart.getXYPlot().setRenderer(renderer); dataSet.addChangeListener(new DatasetChangeListener() { @Override public void datasetChanged(DatasetChangeEvent event) { chart.getPlot().datasetChanged(event); } }); // creation of the statistics composite FormToolkit toolkit = new FormToolkit(parent.getDisplay()); section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT); section.setBackground(parent.getBackground()); section.setDescription(""); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent // Composite for storing the data Composite composite = toolkit.createComposite(section, SWT.WRAP); composite.setBackground(parent.getBackground()); composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent toolkit.paintBordersFor(composite); section.setClient(composite); for (int j = 0; j < STAT_PROPS.length; j++) { Label label = new Label(composite, SWT.None); label.setText(STAT_PROPS[j] + ":"); labels[j] = new Label(composite, SWT.None); labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); } }
From source file:org.gumtree.vis.plot1d.Plot1D.java
public void plot() { createChart();// w ww . ja v a2 s . c om final Frame frame = SWT_AWT.new_Frame(this); panel = new Plot1DPanel(chart); panel.setHorizontalAxisTrace(true); panel.setVerticalAxisTrace(true); panel.setDoubleBuffered(true); panel.setFillZoomRectangle(true); panel.setZoomAroundAnchor(true); panel.setZoomInFactor(defaultZoomInFactor); panel.setZoomOutFactor(defaultZoomOutFactor); frame.add(panel); createStatusBar(); addListeners(); }
From source file:com.microsoft.tfs.client.common.ui.controls.generic.CompatibleBrowser.java
public CompatibleBrowser(final Composite parent, final int style) { super(parent, style); Check.notNull(parent, "parent"); //$NON-NLS-1$ final GridLayout gridLayout = new GridLayout(1, true); gridLayout.marginHeight = 0;/*from ww w . j a v a2s .co m*/ gridLayout.marginWidth = 0; setLayout(gridLayout); if (isNativeBrowserAvailable()) { log.info(MessageFormat.format("{0} using SWT Browser", CompatibleBrowser.class.getName())); //$NON-NLS-1$ final GridData gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.grabExcessVerticalSpace = true; gd.verticalAlignment = SWT.FILL; browser = new Browser(this, style); browser.setLayoutData(gd); editorPane = null; } else { log.info(MessageFormat.format("{0} using JEditorPane", CompatibleBrowser.class.getName())); //$NON-NLS-1$ browser = null; JEditorPane tempEditorPane = null; CompatibilityLinkControl tempErrorLabel = null; /* * Embedded AWT widgets must be in a Composite with SWT.EMBEDDED * set, so create one. */ final Composite embeddableComposite = new Composite(this, SWT.EMBEDDED); final GridData compositeGridData = new GridData(); compositeGridData.grabExcessHorizontalSpace = true; compositeGridData.horizontalAlignment = SWT.FILL; compositeGridData.grabExcessVerticalSpace = true; compositeGridData.verticalAlignment = SWT.FILL; embeddableComposite.setLayoutData(compositeGridData); /* * We have to skip trying AWT entirely some places. */ boolean loadedAWTBrowser = false; if (CompatibleBrowser.isAWTDangerousHere() == false) { try { /* * Create a Frame in the SWT Composite as the top-level * element. */ final Frame browserFrame = SWT_AWT.new_Frame(embeddableComposite); /* * Create a panel with a simple BorderLayout to hold * contents. */ final Panel panel = new Panel(new BorderLayout()); browserFrame.add(panel); /* * Create an JEditorPane with an HTML document. */ final String pageContents = "<html><body></body></html>"; //$NON-NLS-1$ tempEditorPane = new JEditorPane("text/html", pageContents); //$NON-NLS-1$ tempEditorPane.setEditable(false); /* * Put the HTML viewer in a scroll pane and parent the * scroll pane in the panel. */ final JScrollPane scrollPane = new JScrollPane(tempEditorPane); panel.add(scrollPane); loadedAWTBrowser = true; } catch (final Throwable t) { log.warn("Error embedding AWT frame for JEditorPane", t); //$NON-NLS-1$ } } if (loadedAWTBrowser == false) { /* * We don't need the embeddable composite because AWT embedding * failed, and we can't put normal (error label) things in it, * so hide it. */ compositeGridData.widthHint = 0; compositeGridData.heightHint = 0; tempErrorLabel = CompatibilityLinkFactory.createLink(this, SWT.NONE); tempErrorLabel.setText( MessageFormat.format(Messages.getString("CompatibleBrowser.CouldNotLoadSWTBrowserFormat"), //$NON-NLS-1$ AWT_TOOLKIT_ENV_VAR_NAME, XTOOLKIT_ENV_VAR_VALUE)); final GridData labelGridData = new GridData(); labelGridData.grabExcessHorizontalSpace = true; labelGridData.horizontalAlignment = SWT.FILL; labelGridData.grabExcessVerticalSpace = true; labelGridData.verticalAlignment = SWT.FILL; tempErrorLabel.getControl().setLayoutData(labelGridData); } editorPane = tempEditorPane; } }
From source file:org.gumtree.vis.hist2d.Hist2D.java
public void plot() { createChart();/*from www . jav a2s . com*/ final Frame frame = SWT_AWT.new_Frame(this); panel = new Hist2DPanel(chart); panel.setHorizontalAxisTrace(true); panel.setVerticalAxisTrace(true); panel.setDoubleBuffered(true); panel.setFillZoomRectangle(true); panel.setZoomAroundAnchor(true); panel.setZoomInFactor(defaultZoomInFactor); panel.setZoomOutFactor(defaultZoomOutFactor); frame.add(panel); createStatusBar(); addListeners(); }
From source file:com.mirth.connect.plugins.rtfviewer.RTFViewer.java
@Override public void viewAttachments(List<String> attachmentIds) { // do viewing code Frame frame = new Frame("RTF Viewer"); frame.setLayout(new BorderLayout()); try {//from w w w . j av a2 s . c o m Attachment attachment = parent.mirthClient.getAttachment(attachmentIds.get(0)); byte[] rawRTF = Base64.decodeBase64(attachment.getData()); JEditorPane jEditorPane = new JEditorPane("text/rtf", new String(rawRTF)); if (jEditorPane.getDocument().getLength() == 0) { // decoded when it should not have been. i.e.) the attachment data was not encoded. jEditorPane.setText(new String(attachment.getData())); } jEditorPane.setEditable(false); JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.setViewportView(jEditorPane); frame.add(scrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.setSize(600, 800); Dimension dlgSize = frame.getSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { frame.setLocationRelativeTo(null); } else { frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } frame.setVisible(true); } catch (Exception e) { parent.alertException(parent, e.getStackTrace(), e.getMessage()); } }
From source file:com.mirth.connect.plugins.textviewer.TextViewer.java
@Override public void viewAttachments(String channelId, Long messageId, String attachmentId) { // do viewing code Frame frame = new Frame("Text Viewer"); frame.setLayout(new BorderLayout()); try {//from w ww. j av a2s. co m Attachment attachment = parent.mirthClient.getAttachment(channelId, messageId, attachmentId); byte[] content = Base64.decodeBase64(attachment.getContent()); boolean isRTF = attachment.getType().toLowerCase().contains("rtf"); //TODO set character encoding JEditorPane jEditorPane = new JEditorPane(isRTF ? "text/rtf" : "text/plain", new String(content)); if (jEditorPane.getDocument().getLength() == 0) { // decoded when it should not have been. i.e.) the attachment data was not encoded. jEditorPane.setText(new String(attachment.getContent())); } jEditorPane.setEditable(false); JScrollPane scrollPane = new javax.swing.JScrollPane(); scrollPane.setViewportView(jEditorPane); frame.add(scrollPane); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.setSize(600, 800); Dimension dlgSize = frame.getSize(); Dimension frmSize = parent.getSize(); Point loc = parent.getLocation(); if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) { frame.setLocationRelativeTo(null); } else { frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y); } frame.setVisible(true); } catch (Exception e) { parent.alertThrowable(parent, e); } }