List of usage examples for javax.swing JTextPane setContentType
@BeanProperty(bound = false, description = "the type of content") public final void setContentType(String type)
From source file:esmska.gui.AboutFrame.java
private void licenseButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_licenseButtonActionPerformed //show licence try {/* w w w.j a v a 2s .co m*/ logger.fine("Showing license..."); String license = IOUtils.toString(getClass().getResourceAsStream(RES + "license.txt"), "UTF-8"); final String agpl = IOUtils.toString(getClass().getResourceAsStream(RES + "gnu-agpl.txt"), "UTF-8"); license = MiscUtils.escapeHtml(license); license = license.replaceAll("GNU Affero General Public License", "<a href=\"agpl\">GNU Affero General Public License</a>"); final JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText("<html><pre>" + license + "</pre></html>"); tp.setEditable(false); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); tp.setPreferredSize(new Dimension((int) d.getWidth() / 2, (int) d.getHeight() / 2)); //reasonable size tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { logger.fine("Showing GNU AGPL..."); tp.setText(null); tp.setContentType("text/plain"); tp.setText(agpl); tp.setCaretPosition(0); } } }); String option = l10n.getString("AboutFrame.Acknowledge"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.License")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException ex) { logger.log(Level.WARNING, "Could not show license", ex); } }
From source file:esmska.gui.AboutFrame.java
private void creditsButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_creditsButtonActionPerformed //show credits try {/*from ww w.j a v a 2 s. c o m*/ logger.fine("Showing credits..."); String credits = IOUtils.toString(getClass().getResourceAsStream(RES + "credits.html"), "UTF-8"); String translators = l10n.getString("Translators"); if ("translator-credits".equals(translators)) { //there are no translators mentioned translators = ""; } else { translators = translators.replaceAll("\n", "<br>\n").replaceAll("\n ", "\n "); //add hyperlinks to the Launchpad URLs translators = translators.replaceAll("(https://[^<]*)", "<a href=\"$1\">$1</a>"); } String document = MessageFormat.format(credits, l10n.getString("Credits.authors"), l10n.getString("Credits.contributors"), l10n.getString("Credits.graphics"), l10n.getString("Credits.sponsors"), l10n.getString("Credits.translators"), translators, Links.DONATORS, l10n.getString("Credits.moreDonators"), MessageFormat.format(l10n.getString("Credits.packagers"), Links.DOWNLOAD)); JTextPane tp = new JTextPane(); tp.setContentType("text/html; charset=UTF-8"); tp.setText(document); tp.setEditable(false); tp.setPreferredSize(new Dimension(450, 400)); tp.setCaretPosition(0); //make links clickable tp.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && Desktop.isDesktopSupported()) { try { logger.fine("Browsing URL: " + e.getURL()); Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { logger.log(Level.SEVERE, "Can't browse hyperlink: " + e.getURL(), ex); } } } }); String option = l10n.getString("AboutFrame.Thank_you"); JOptionPane op = new JOptionPane(new JScrollPane(tp), JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] { option }, option); JDialog dialog = op.createDialog(this, l10n.getString("AboutFrame.Credits")); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } catch (IOException e) { logger.log(Level.WARNING, "Could not show credits", e); } }
From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java
private JTextPane getStyledTextPane() { JTextPane pane = new JTextPane(); pane.setContentType(CONTENT_TYPE); StyleSheet sheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet(); sheet.addRule(BODY_STYLE);//from w ww. java2s . c om sheet.addRule(ADDITION_STYLE); sheet.addRule(REMOVAL_STYLE); sheet.addRule(CHANGE_STYLE); pane.setEditable(false); return pane; }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Displays help window/*from ww w .j a va 2s .c o m*/ */ private void help() { String msg = ""; MutableDataSet options = new MutableDataSet(); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); try { msg = IOUtils.toString(Main.getFile("Usage.md", this)); Node document = parser.parse(msg); msg = renderer.render(document); } catch (IOException e) { e.printStackTrace(); } JTextPane area = new JTextPane(); area.setContentType("text/html"); area.setText(msg); area.setCaretPosition(0); area.setEditable(false); JScrollPane scrollPane = new JScrollPane(area); scrollPane .setMaximumSize(new Dimension(GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height)); scrollPane.setPreferredSize( new Dimension(GraphicsRunner.SCREEN_SIZE.width - 10, GraphicsRunner.SCREEN_SIZE.height - 10)); scrollPane.scrollRectToVisible(new Rectangle()); JOptionPane.showMessageDialog(this, scrollPane, "Help", JOptionPane.PLAIN_MESSAGE); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * /*from w w w . j a v a2 s. c o m*/ */ protected void buildUI() { SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr); localizableIO = slxh; localizableIO.load(false); //stripToSingleLocale("pt", slxh); LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() { public LocalizableStrIFace create() { SpLocaleItemStr str = new SpLocaleItemStr(); str.initialize(); return str; } public LocalizableStrIFace create(String text, Locale locale) { return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor } }; LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory); SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory); schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, webLinkMgrCache, schemaType); schemaLocPanel.setLocalizableIO(localizableIO); schemaLocPanel.setStatusBar(statusBar); boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false); schemaLocPanel.setUseDisciplines(useDisciplines); // rods - for now //schemaLocPanel.setIncludeHiddenUI(true); schemaLocPanel.buildUI(); schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad()); statusBar.setSectionText(1, schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$ : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$ UIRegistry.setStatusBar(statusBar); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); String title = "File"; //$NON-NLS-1$ String mneu = "F"; //$NON-NLS-1$ JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "Save"; //$NON-NLS-1$ mneu = "S"; //$NON-NLS-1$ JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$ new ActionListener() { public void actionPerformed(ActionEvent e) { write(); } }); saveMenuItem.setEnabled(false); title = "Export"; //$NON-NLS-1$ mneu = "E"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { export(); } }); title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$ mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { exportSingleLocale(); } }); title = "Exit"; //$NON-NLS-1$ mneu = "x"; //$NON-NLS-1$ if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } /* JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T"); UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener() { public void actionPerformed(ActionEvent e) { createResourceFiles(); } }); */ menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$ { schemaLocPanel.localeChanged((Locale) evt.getNewValue()); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); } } })); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setSize(800, 600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(schemaLocPanel, BorderLayout.CENTER); mainPanel.add(statusBar, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setContentPane(mainPanel); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); schemaLocPanel.setSaveMenuItem(saveMenuItem); schemaLocPanel.getContainerList().setEnabled(true); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.loadColorAndFormatPrefs(); if (localizableIO.didModelChangeDuringLoad()) { saveMenuItem.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); tp.setContentType("text/html"); tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer()); frame.setContentPane(js); frame.pack(); frame.setSize(400, 500); frame.setVisible(true); } }); } }
From source file:com.awesomecoding.minetestlauncher.Main.java
private void initialize() { fileGetter = new FileGetter(userhome + "\\minetest\\temp\\"); latest = fileGetter.getContents("http://socialmelder.com/minetest/latest.txt", true); currentVersion = latest.split("\n")[0]; changelog = fileGetter.getContents("http://socialmelder.com/minetest/changelog.html", false); try {//from w ww .ja v a 2s .com UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } frmMinetestLauncherV = new JFrame(); frmMinetestLauncherV.setResizable(false); frmMinetestLauncherV.setIconImage(Toolkit.getDefaultToolkit() .getImage(Main.class.getResource("/com/awesomecoding/minetestlauncher/icon.png"))); frmMinetestLauncherV.setTitle("Minetest Launcher (Version 0.1)"); frmMinetestLauncherV.setBounds(100, 100, 720, 480); frmMinetestLauncherV.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpringLayout springLayout = new SpringLayout(); frmMinetestLauncherV.getContentPane().setLayout(springLayout); final JProgressBar progressBar = new JProgressBar(); springLayout.putConstraint(SpringLayout.WEST, progressBar, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, progressBar, -10, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.EAST, progressBar, -130, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(progressBar); final JButton btnDownloadPlay = new JButton("Play!"); springLayout.putConstraint(SpringLayout.WEST, btnDownloadPlay, 6, SpringLayout.EAST, progressBar); springLayout.putConstraint(SpringLayout.SOUTH, btnDownloadPlay, 0, SpringLayout.SOUTH, progressBar); springLayout.putConstraint(SpringLayout.EAST, btnDownloadPlay, -10, SpringLayout.EAST, frmMinetestLauncherV.getContentPane()); frmMinetestLauncherV.getContentPane().add(btnDownloadPlay); final JLabel label = new JLabel("Ready to play!"); springLayout.putConstraint(SpringLayout.WEST, label, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, btnDownloadPlay, 0, SpringLayout.NORTH, label); springLayout.putConstraint(SpringLayout.SOUTH, label, -37, SpringLayout.SOUTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.NORTH, progressBar, 6, SpringLayout.SOUTH, label); frmMinetestLauncherV.getContentPane().add(label); JTextPane txtpnNewFeatures = new JTextPane(); txtpnNewFeatures.setBackground(SystemColor.window); springLayout.putConstraint(SpringLayout.NORTH, txtpnNewFeatures, 10, SpringLayout.NORTH, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.WEST, txtpnNewFeatures, 10, SpringLayout.WEST, frmMinetestLauncherV.getContentPane()); springLayout.putConstraint(SpringLayout.SOUTH, txtpnNewFeatures, -10, SpringLayout.NORTH, btnDownloadPlay); springLayout.putConstraint(SpringLayout.EAST, txtpnNewFeatures, 0, SpringLayout.EAST, btnDownloadPlay); txtpnNewFeatures.setEditable(false); txtpnNewFeatures.setContentType("text/html"); txtpnNewFeatures.setText(changelog); txtpnNewFeatures.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmMinetestLauncherV.getContentPane().add(txtpnNewFeatures); File file = new File(userhome + "\\minetest\\version.txt"); if (!file.exists()) newVersion = true; else { String version = fileGetter.getLocalContents(file, false); if (!version.equals(currentVersion)) newVersion = true; } if (newVersion) { label.setText("New Version Available! (" + currentVersion + ")"); btnDownloadPlay.setText("Download & Play"); btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Thread t = new Thread() { public void run() { File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); try { FileUtils.deleteDirectory(new File(userhome + "\\minetest\\minetest-" + version)); } catch (Exception e) { e.printStackTrace(); } fileGetter.download(latest.split("\n")[1], userhome + "\\minetest\\temp\\", "minetest.zip", label, progressBar, btnDownloadPlay, currentVersion); try { label.setText("Cleaning up..."); btnDownloadPlay.setText("Cleaning up..."); FileUtils.deleteDirectory(new File(userhome + "\\minetest\\temp")); } catch (IOException e) { e.printStackTrace(); } System.exit(0); } }; t.start(); } }); } else { btnDownloadPlay.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { label.setText("Launching..."); btnDownloadPlay.setEnabled(false); btnDownloadPlay.setText("Launching..."); File file = new File(userhome + "\\minetest\\version.txt"); String version = fileGetter.getLocalContents(file, false); Runtime.getRuntime() .exec(userhome + "\\minetest\\minetest-" + version + "\\bin\\minetest.exe"); System.exit(0); } catch (IOException e) { e.printStackTrace(); } } }); progressBar.setValue(100); } }
From source file:de.ailis.xadrian.components.ComplexEditor.java
/** * Prints the complex data//from w w w . j a v a 2 s . c o m */ public void print() { // Prepare model final Map<String, Object> model = new HashMap<String, Object>(); model.put("complex", this.complex); model.put("print", true); model.put("config", Config.getInstance()); // Generate content final String content = TemplateFactory.processTemplate(template, model); // Put content into a text pane component final JTextPane printPane = new JTextPane(); printPane.setContentType("text/html"); ((HTMLDocument) printPane.getDocument()).setBase(Main.class.getResource("templates/")); printPane.setText(content); // Print the text pane try { printPane.print(null, null, true, null, Config.getInstance().getPrintAttributes(), true); } catch (final PrinterException e) { JOptionPane.showMessageDialog(null, I18N.getString("error.cantPrint"), I18N.getString("error.title"), JOptionPane.ERROR_MESSAGE); log.error("Unable to print complex: " + e, e); } }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java
public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) { setLayout(new BorderLayout()); this.label = label; igbLogger = IGBLogger.getInstance(label); colorer = TaxonColorer.getColorer(query.getTaxid()); Box menuBox = new Box(BoxLayout.X_AXIS); Box buttonBox = new Box(BoxLayout.Y_AXIS); Box buttonBox1 = new Box(BoxLayout.X_AXIS); Box buttonBox3 = new Box(BoxLayout.X_AXIS); buttonBox.add(buttonBox1);/* w w w.j a v a 2 s .co m*/ buttonBox.add(buttonBox3); JTextPane querySummary = new JTextPane(); querySummary.setContentType("text/html"); querySummary.setEditable(false); querySummary.setText(summary); menuBox.add(querySummary); menuBox.add(buttonBox); final JFrame logFrame = new JFrame("MI Bundle Log"); logFrame.setVisible(false); Dimension preferredSize = new Dimension(800, 500); logFrame.setPreferredSize(preferredSize); logFrame.setMinimumSize(preferredSize); logFrame.add(new LogPanel(igbLogger)); JButton log = new JButton(); if (igbLogger.hasError()) { log.setBackground(Color.red); } log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png")); log.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logFrame.setVisible(true); } }); buttonBox1.add(log); JButton networkButton = new JButton(""); networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg"))); networkButton.addActionListener(new DisplayNetworkActionListener()); buttonBox1.add(networkButton); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Save: ")); JButton exportButton = new JButton("text"); exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportButton.addActionListener(new ExportActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportButton); } JButton exportXgmmlButton = new JButton("xgmml"); exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportXgmmlButton.addActionListener(new ExportXgmmlActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportXgmmlButton); } buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("View structure: ")); structures = new StructuresPanel(service, label); buttonBox1.add(structures.getJmolButton()); buttonBox1.add(structures.getLinkButton()); // Filters ButtonGroup scoreGroup = new ButtonGroup(); JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>"); JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>"); JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>"); JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>"); scoreButton0.setSelected(true); ScoreListener scoreListener = new ScoreListener(); scoreButton0.addActionListener(scoreListener); scoreButton1.addActionListener(scoreListener); scoreButton2.addActionListener(scoreListener); scoreButton3.addActionListener(scoreListener); scoreGroup.add(scoreButton0); scoreGroup.add(scoreButton1); scoreGroup.add(scoreButton2); scoreGroup.add(scoreButton3); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Score: ")); buttonBox1.add(scoreButton0); buttonBox1.add(scoreButton1); buttonBox1.add(scoreButton2); buttonBox1.add(scoreButton3); buttonBox3.add(new JLabel("Interaction type: ")); JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL); JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION); JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC); JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER); JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED); JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE); EvidencePhysicalButton.setSelected(true); EvidenceAssociationButton.setSelected(true); EvidenceEnzymaticButton.setSelected(true); EvidenceOtherButton.setSelected(true); EvidenceUnspecifiedButton.setSelected(true); EvidenceStructureButton.setSelected(true); buttonBox3.add(EvidencePhysicalButton); buttonBox3.add(EvidenceAssociationButton); buttonBox3.add(EvidenceEnzymaticButton); buttonBox3.add(EvidenceOtherButton); buttonBox3.add(EvidenceUnspecifiedButton); buttonBox3.add(EvidenceStructureButton); EvidenceTypeListener evidenceListener = new EvidenceTypeListener(); EvidencePhysicalButton.addActionListener(evidenceListener); EvidenceAssociationButton.addActionListener(evidenceListener); EvidenceEnzymaticButton.addActionListener(evidenceListener); EvidenceOtherButton.addActionListener(evidenceListener); EvidenceUnspecifiedButton.addActionListener(evidenceListener); EvidenceStructureButton.addActionListener(evidenceListener); Box tableBox = new Box(BoxLayout.Y_AXIS); MITableModel model = new MITableModel(results); miTable = new MITable(model, service, query); miTable.setFillsViewportHeight(true); miTable.setStructuresPanel(structures); tableBox.add(miTable.getTableHeader()); tableBox.add(miTable); JScrollPane tableScroll = new JScrollPane(tableBox); tableScroll.setMinimumSize(new Dimension(800, 50)); tableScroll.setPreferredSize(new Dimension(800, 50)); tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); structures.setMinimumSize(new Dimension(200, 500)); structures.setPreferredSize(new Dimension(200, 500)); structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE)); resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures); resultBox.setOneTouchExpandable(true); add(menuBox, BorderLayout.NORTH); add(resultBox, BorderLayout.CENTER); }
From source file:juicebox.windowui.QCDialog.java
public QCDialog(MainWindow mainWindow, HiC hic, String title) { super(mainWindow); Dataset dataset = hic.getDataset();// ww w. j a v a2 s.c o m String text = dataset.getStatistics(); String textDescription = null; String textStatistics = null; String graphs = dataset.getGraphs(); JTextPane description = null; JTabbedPane tabbedPane = new JTabbedPane(); HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styleSheet = kit.getStyleSheet(); styleSheet.addRule("table { border-collapse: collapse;}"); styleSheet.addRule("body {font-family: Sans-Serif; font-size: 12;}"); styleSheet.addRule("td { padding: 2px; }"); styleSheet.addRule( "th {border-bottom: 1px solid #000; text-align: left; background-color: #D8D8D8; font-weight: normal;}"); if (text != null) { int split = text.indexOf("</table>") + 8; textDescription = text.substring(0, split); textStatistics = text.substring(split); description = new JTextPane(); description.setEditable(false); description.setContentType("text/html"); description.setEditorKit(kit); description.setText(textDescription); tabbedPane.addTab("About Library", description); JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setContentType("text/html"); textPane.setEditorKit(kit); textPane.setText(textStatistics); JScrollPane pane = new JScrollPane(textPane); tabbedPane.addTab("Statistics", pane); } boolean success = true; if (graphs != null) { long[] A = new long[2000]; long sumA = 0; long[] mapq1 = new long[201]; long[] mapq2 = new long[201]; long[] mapq3 = new long[201]; long[] intraCount = new long[100]; final XYSeries intra = new XYSeries("Intra Count"); final XYSeries leftRead = new XYSeries("Left"); final XYSeries rightRead = new XYSeries("Right"); final XYSeries innerRead = new XYSeries("Inner"); final XYSeries outerRead = new XYSeries("Outer"); final XYSeries allMapq = new XYSeries("All MapQ"); final XYSeries intraMapq = new XYSeries("Intra MapQ"); final XYSeries interMapq = new XYSeries("Inter MapQ"); Scanner scanner = new Scanner(graphs); try { while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 2000; idx++) { A[idx] = scanner.nextLong(); sumA += A[idx]; } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 201; idx++) { mapq1[idx] = scanner.nextInt(); mapq2[idx] = scanner.nextInt(); mapq3[idx] = scanner.nextInt(); } for (int idx = 199; idx >= 0; idx--) { mapq1[idx] = mapq1[idx] + mapq1[idx + 1]; mapq2[idx] = mapq2[idx] + mapq2[idx + 1]; mapq3[idx] = mapq3[idx] + mapq3[idx + 1]; allMapq.add(idx, mapq1[idx]); intraMapq.add(idx, mapq2[idx]); interMapq.add(idx, mapq3[idx]); } while (!scanner.next().equals("[")) ; for (int idx = 0; idx < 100; idx++) { int tmp = scanner.nextInt(); if (tmp != 0) innerRead.add(logXAxis[idx], tmp); intraCount[idx] = tmp; tmp = scanner.nextInt(); if (tmp != 0) outerRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) rightRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; tmp = scanner.nextInt(); if (tmp != 0) leftRead.add(logXAxis[idx], tmp); intraCount[idx] += tmp; if (idx > 0) intraCount[idx] += intraCount[idx - 1]; if (intraCount[idx] != 0) intra.add(logXAxis[idx], intraCount[idx]); } } catch (NoSuchElementException exception) { JOptionPane.showMessageDialog(getParent(), "Graphing file improperly formatted", "Error", JOptionPane.ERROR_MESSAGE); success = false; } if (success) { final XYSeriesCollection readTypeCollection = new XYSeriesCollection(); readTypeCollection.addSeries(innerRead); readTypeCollection.addSeries(outerRead); readTypeCollection.addSeries(leftRead); readTypeCollection.addSeries(rightRead); final JFreeChart readTypeChart = ChartFactory.createXYLineChart("Types of reads vs distance", // chart title "Distance (log)", // domain axis label "Binned Reads (log)", // range axis label readTypeCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Binned Reads (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel = new ChartPanel(readTypeChart); final XYSeriesCollection reCollection = new XYSeriesCollection(); final XYSeries reDistance = new XYSeries("Distance"); for (int i = 0; i < A.length; i++) { if (A[i] != 0) reDistance.add(i, A[i] / (float) sumA); } reCollection.addSeries(reDistance); final JFreeChart reChart = ChartFactory.createXYLineChart( "Distance from closest restriction enzyme site", // chart title "Distance (bp)", // domain axis label "Fraction of Reads (log)", // range axis label reCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot rePlot = reChart.getXYPlot(); rePlot.setDomainAxis(new NumberAxis("Distance (bp)")); rePlot.setRangeAxis(new LogarithmicAxis("Fraction of Reads (log)")); rePlot.setBackgroundPaint(Color.white); rePlot.setRangeGridlinePaint(Color.lightGray); rePlot.setDomainGridlinePaint(Color.lightGray); reChart.setBackgroundPaint(Color.white); rePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel2 = new ChartPanel(reChart); final XYSeriesCollection intraCollection = new XYSeriesCollection(); intraCollection.addSeries(intra); final JFreeChart intraChart = ChartFactory.createXYLineChart("Intra reads vs distance", // chart title "Distance (log)", // domain axis label "Cumulative Sum of Binned Reads (log)", // range axis label intraCollection, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot intraPlot = intraChart.getXYPlot(); intraPlot.setDomainAxis(new LogarithmicAxis("Distance (log)")); intraPlot.setRangeAxis(new NumberAxis("Cumulative Sum of Binned Reads (log)")); intraPlot.setBackgroundPaint(Color.white); intraPlot.setRangeGridlinePaint(Color.lightGray); intraPlot.setDomainGridlinePaint(Color.lightGray); intraChart.setBackgroundPaint(Color.white); intraPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel3 = new ChartPanel(intraChart); final XYSeriesCollection mapqCollection = new XYSeriesCollection(); mapqCollection.addSeries(allMapq); mapqCollection.addSeries(intraMapq); mapqCollection.addSeries(interMapq); final JFreeChart mapqChart = ChartFactory.createXYLineChart("MapQ Threshold Count", // chart title "MapQ threshold", // domain axis label "Count", // range axis label mapqCollection, // data PlotOrientation.VERTICAL, true, // include legend true, // include tooltips false); final XYPlot mapqPlot = mapqChart.getXYPlot(); mapqPlot.setBackgroundPaint(Color.white); mapqPlot.setRangeGridlinePaint(Color.lightGray); mapqPlot.setDomainGridlinePaint(Color.lightGray); mapqChart.setBackgroundPaint(Color.white); mapqPlot.setOutlinePaint(Color.black); final ChartPanel chartPanel4 = new ChartPanel(mapqChart); tabbedPane.addTab("Pair Type", chartPanel); tabbedPane.addTab("Restriction", chartPanel2); tabbedPane.addTab("Intra vs Distance", chartPanel3); tabbedPane.addTab("MapQ", chartPanel4); } } final ExpectedValueFunction df = hic.getDataset().getExpectedValues(hic.getZoom(), hic.getNormalizationType()); if (df != null) { double[] expected = df.getExpectedValues(); final XYSeriesCollection collection = new XYSeriesCollection(); final XYSeries expectedValues = new XYSeries("Expected"); for (int i = 0; i < expected.length; i++) { if (expected[i] > 0) expectedValues.add(i + 1, expected[i]); } collection.addSeries(expectedValues); String title1 = "Expected at " + hic.getZoom() + " norm " + hic.getNormalizationType(); final JFreeChart readTypeChart = ChartFactory.createXYLineChart(title1, // chart title "Distance between reads (log)", // domain axis label "Genome-wide expected (log)", // range axis label collection, // data PlotOrientation.VERTICAL, false, // include legend true, false); final XYPlot readTypePlot = readTypeChart.getXYPlot(); readTypePlot.setDomainAxis(new LogarithmicAxis("Distance between reads (log)")); readTypePlot.setRangeAxis(new LogarithmicAxis("Genome-wide expected (log)")); readTypePlot.setBackgroundPaint(Color.white); readTypePlot.setRangeGridlinePaint(Color.lightGray); readTypePlot.setDomainGridlinePaint(Color.lightGray); readTypeChart.setBackgroundPaint(Color.white); readTypePlot.setOutlinePaint(Color.black); final ChartPanel chartPanel5 = new ChartPanel(readTypeChart); tabbedPane.addTab("Expected", chartPanel5); } if (text == null && graphs == null) { JOptionPane.showMessageDialog(this, "Sorry, no metrics are available for this dataset", "Error", JOptionPane.ERROR_MESSAGE); setVisible(false); dispose(); } else { getContentPane().add(tabbedPane); pack(); setModal(false); setLocation(100, 100); setTitle(title); setVisible(true); } }
From source file:com.vgi.mafscaling.LogView.java
private void createUsageTab() { JTextPane usageTextArea = new JTextPane(); usageTextArea.setMargin(new Insets(10, 10, 10, 10)); usageTextArea.setContentType("text/html"); usageTextArea.setText(usage());//from w w w . j av a 2 s . c om usageTextArea.setEditable(false); usageTextArea.setCaretPosition(0); JScrollPane textScrollPane = new JScrollPane(usageTextArea); textScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); textScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); add(textScrollPane, "<html><div style='text-align: center;'>U<br>s<br>a<br>g<br>e</div></html>"); }