Example usage for javax.swing JEditorPane JEditorPane

List of usage examples for javax.swing JEditorPane JEditorPane

Introduction

In this page you can find the example usage for javax.swing JEditorPane JEditorPane.

Prototype

public JEditorPane() 

Source Link

Document

Creates a new JEditorPane.

Usage

From source file:net.yacy.cora.util.Html2Image.java

/**
 * render a html page with a JEditorPane, which can do html up to html v 3.2. No CSS supported!
 * @param url/*from ww  w .ja v a2s  . co  m*/
 * @param size
 * @throws IOException 
 */
public static void writeSwingImage(String url, Dimension size, File destination) throws IOException {

    // set up a pane for rendering
    final JEditorPane htmlPane = new JEditorPane();
    htmlPane.setSize(size);
    htmlPane.setEditable(false);
    final HTMLEditorKit kit = new HTMLEditorKit() {

        private static final long serialVersionUID = 1L;

        @Override
        public Document createDefaultDocument() {
            HTMLDocument doc = (HTMLDocument) super.createDefaultDocument();
            doc.setAsynchronousLoadPriority(-1);
            return doc;
        }

        @Override
        public ViewFactory getViewFactory() {
            return new HTMLFactory() {
                @Override
                public View create(Element elem) {
                    View view = super.create(elem);
                    if (view instanceof ImageView) {
                        ((ImageView) view).setLoadsSynchronously(true);
                    }
                    return view;
                }
            };
        }
    };
    htmlPane.setEditorKitForContentType("text/html", kit);
    htmlPane.setContentType("text/html");
    htmlPane.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
        }
    });

    // load the page
    try {
        htmlPane.setPage(url);
    } catch (IOException e) {
        e.printStackTrace();
    }

    // render the page
    Dimension prefSize = htmlPane.getPreferredSize();
    BufferedImage img = new BufferedImage(prefSize.width, htmlPane.getPreferredSize().height,
            BufferedImage.TYPE_INT_ARGB);
    Graphics graphics = img.getGraphics();
    htmlPane.setSize(prefSize);
    htmlPane.paint(graphics);
    ImageIO.write(img, destination.getName().endsWith("jpg") ? "jpg" : "png", destination);
}

From source file:nz.govt.natlib.ndha.manualdeposit.HelpWindow.java

/** Creates new form HelpWindow */
public HelpWindow(final String title, final URL hlpURL, final String settingsPath) {
    super(title);
    try {//from   ww w  . j a va 2  s . c o  m
        frmControl = new FormControl(this, settingsPath);
    } catch (Exception ex) {
        LOG.error("Error loading form parameters", ex);
    }
    helpURL = hlpURL;
    editorpane = new JEditorPane();
    editorpane.setEditable(false);
    try {
        editorpane.setPage(helpURL);
    } catch (Exception ex) {
        LOG.error(ex.getMessage(), ex);
    }
    // anonymous inner listener
    editorpane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(final HyperlinkEvent ev) {
            try {
                if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    editorpane.setPage(ev.getURL());
                }
            } catch (IOException ex) {
                // put message in window
                LOG.error(ex.getMessage(), ex);
            }
        }
    });
    getContentPane().add(new JScrollPane(editorpane));
    addButtons();
    // no need for listener just dispose
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setVisible(true);
}

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Activates itself as a viewer by configuring Size, and location of itself,
 * and configures the default Tabbed Pane elements with the correct layout,
 * table columns, and sets itself viewable.
 */// w  w  w .ja v a2  s  .com
public void activateViewer() {
    LoggerRepository repo = LogManager.getLoggerRepository();
    if (repo instanceof LoggerRepositoryEx) {
        this.pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry();
    }
    initGUI();

    initPrefModelListeners();

    /**
     * We add a simple appender to the MessageCenter logger
     * so that each message is displayed in the Status bar
     */
    MessageCenter.getInstance().getLogger().addAppender(new AppenderSkeleton() {
        protected void append(LoggingEvent event) {
            getStatusBar().setMessage(event.getMessage().toString());
        }

        public void close() {
        }

        public boolean requiresLayout() {
            return false;
        }
    });

    initSocketConnectionListener();

    if (pluginRegistry.getPlugins(Receiver.class).size() == 0) {
        noReceiversDefined = true;
    }

    getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.THREAD_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.NDC_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.PROPERTIES_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.CLASS_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.METHOD_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.FILE_COL_NAME);
    getFilterableColumns().add(ChainsawConstants.NONE_COL_NAME);

    JPanel panePanel = new JPanel();
    panePanel.setLayout(new BorderLayout(2, 2));

    getContentPane().setLayout(new BorderLayout());

    getTabbedPane().addChangeListener(getToolBarAndMenus());
    getTabbedPane().addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            LogPanel thisLogPanel = getCurrentLogPanel();
            if (thisLogPanel != null) {
                thisLogPanel.updateStatusBar();
            }
        }
    });

    KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    KeyStroke ksLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    KeyStroke ksGotoLine = KeyStroke.getKeyStroke(KeyEvent.VK_G,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksRight, "MoveRight");
    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksLeft, "MoveLeft");
    getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksGotoLine, "GotoLine");

    Action moveRight = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            int temp = getTabbedPane().getSelectedIndex();
            ++temp;

            if (temp != getTabbedPane().getTabCount()) {
                getTabbedPane().setSelectedTab(temp);
            }
        }
    };

    Action moveLeft = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            int temp = getTabbedPane().getSelectedIndex();
            --temp;

            if (temp > -1) {
                getTabbedPane().setSelectedTab(temp);
            }
        }
    };

    Action gotoLine = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number to go:",
                    "Goto Line", -1);
            try {
                int lineNumber = Integer.parseInt(inputLine);
                int row = getCurrentLogPanel().setSelectedEvent(lineNumber);
                if (row == -1) {
                    JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number",
                            "Error", 0);
                }
            } catch (NumberFormatException nfe) {
                JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error",
                        0);
            }
        }
    };

    getTabbedPane().getActionMap().put("MoveRight", moveRight);
    getTabbedPane().getActionMap().put("MoveLeft", moveLeft);
    getTabbedPane().getActionMap().put("GotoLine", gotoLine);

    /**
         * We listen for double clicks, and auto-undock currently selected Tab if
         * the mouse event location matches the currently selected tab
         */
    getTabbedPane().addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);

            if ((e.getClickCount() > 1) && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) {
                int tabIndex = getTabbedPane().getSelectedIndex();

                if ((tabIndex != -1) && (tabIndex == getTabbedPane().getSelectedIndex())) {
                    LogPanel logPanel = getCurrentLogPanel();

                    if (logPanel != null) {
                        logPanel.undock();
                    }
                }
            }
        }
    });

    panePanel.add(getTabbedPane());
    addWelcomePanel();

    getContentPane().add(toolbar, BorderLayout.NORTH);
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    mainReceiverSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panePanel, receiversPanel);
    dividerSize = mainReceiverSplitPane.getDividerSize();
    mainReceiverSplitPane.setDividerLocation(-1);

    getContentPane().add(mainReceiverSplitPane, BorderLayout.CENTER);

    /**
     * We need to make sure that all the internal GUI components have been added to the
     * JFrame so that any plugns that get activated during initPlugins(...) method
     * have access to inject menus  
     */
    initPlugins(pluginRegistry);

    mainReceiverSplitPane.setResizeWeight(1.0);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            exit();
        }
    });
    preferencesFrame.setTitle("'Application-wide Preferences");
    preferencesFrame.setIconImage(((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage());
    preferencesFrame.getContentPane().add(applicationPreferenceModelPanel);

    preferencesFrame.setSize(750, 520);

    Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    preferencesFrame.setLocation(new Point((screenDimension.width / 2) - (preferencesFrame.getSize().width / 2),
            (screenDimension.height / 2) - (preferencesFrame.getSize().height / 2)));

    pack();

    final JPopupMenu tabPopup = new JPopupMenu();
    final Action hideCurrentTabAction = new AbstractAction("Hide") {
        public void actionPerformed(ActionEvent e) {
            Component selectedComp = getTabbedPane().getSelectedComponent();
            if (selectedComp instanceof LogPanel) {
                displayPanel(getCurrentLogPanel().getIdentifier(), false);
                tbms.stateChange();
            } else {
                getTabbedPane().remove(selectedComp);
            }
        }
    };

    final Action hideOtherTabsAction = new AbstractAction("Hide Others") {
        public void actionPerformed(ActionEvent e) {
            Component selectedComp = getTabbedPane().getSelectedComponent();
            String currentName;
            if (selectedComp instanceof LogPanel) {
                currentName = getCurrentLogPanel().getIdentifier();
            } else if (selectedComp instanceof WelcomePanel) {
                currentName = ChainsawTabbedPane.WELCOME_TAB;
            } else {
                currentName = ChainsawTabbedPane.ZEROCONF;
            }

            int count = getTabbedPane().getTabCount();
            int index = 0;

            for (int i = 0; i < count; i++) {
                String name = getTabbedPane().getTitleAt(index);

                if (getPanelMap().keySet().contains(name) && !name.equals(currentName)) {
                    displayPanel(name, false);
                    tbms.stateChange();
                } else {
                    index++;
                }
            }
        }
    };

    Action showHiddenTabsAction = new AbstractAction("Show All Hidden") {
        public void actionPerformed(ActionEvent e) {
            for (Iterator iter = getPanels().entrySet().iterator(); iter.hasNext();) {
                Map.Entry entry = (Map.Entry) iter.next();
                Boolean docked = (Boolean) entry.getValue();
                if (docked.booleanValue()) {
                    String identifier = (String) entry.getKey();
                    int count = getTabbedPane().getTabCount();
                    boolean found = false;

                    for (int i = 0; i < count; i++) {
                        String name = getTabbedPane().getTitleAt(i);

                        if (name.equals(identifier)) {
                            found = true;

                            break;
                        }
                    }

                    if (!found) {
                        displayPanel(identifier, true);
                        tbms.stateChange();
                    }
                }
            }
        }
    };

    tabPopup.add(hideCurrentTabAction);
    tabPopup.add(hideOtherTabsAction);
    tabPopup.addSeparator();
    tabPopup.add(showHiddenTabsAction);

    final PopupListener tabPopupListener = new PopupListener(tabPopup);
    getTabbedPane().addMouseListener(tabPopupListener);

    this.handler.addPropertyChangeListener("dataRate", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            double dataRate = ((Double) evt.getNewValue()).doubleValue();
            statusBar.setDataRate(dataRate);
        }
    });

    getSettingsManager().addSettingsListener(this);
    getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance());
    getSettingsManager().addSettingsListener(receiversPanel);
    try {
        //if an uncaught exception is thrown, allow the UI to continue to load
        getSettingsManager().loadSettings();
    } catch (Exception e) {
        e.printStackTrace();
    }
    //app preferences have already been loaded (and configuration url possibly set to blank if being overridden)
    //but we need a listener so the settings will be saved on exit (added after loadsettings was called)
    getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel));

    setVisible(true);

    if (applicationPreferenceModel.isReceivers()) {
        showReceiverPanel();
    } else {
        hideReceiverPanel();
    }

    removeSplash();

    synchronized (initializationLock) {
        isGUIFullyInitialized = true;
        initializationLock.notifyAll();
    }

    if (noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) {
        SwingHelper.invokeOnEDT(new Runnable() {
            public void run() {
                showReceiverConfigurationPanel();
            }
        });
    }

    Container container = tutorialFrame.getContentPane();
    final JEditorPane tutorialArea = new JEditorPane();
    tutorialArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tutorialArea.setEditable(false);
    container.setLayout(new BorderLayout());

    try {
        tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL);
        JTextComponentFormatter.applySystemFontAndSize(tutorialArea);

        container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER);
    } catch (Exception e) {
        MessageCenter.getInstance().getLogger().error("Error occurred loading the Tutorial", e);
    }

    tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage());
    tutorialFrame.setSize(new Dimension(640, 480));

    final Action startTutorial = new AbstractAction("Start Tutorial",
            new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(null,
                    "This will start 3 \"Generator\" receivers for use in the Tutorial.  Is that ok?",
                    "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                new Thread(new Tutorial()).start();
                putValue("TutorialStarted", Boolean.TRUE);
            } else {
                putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    };

    final Action stopTutorial = new AbstractAction("Stop Tutorial",
            new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) {
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(null,
                    "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched.  Is that ok?",
                    "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                new Thread(new Runnable() {
                    public void run() {
                        LoggerRepository repo = LogManager.getLoggerRepository();
                        if (repo instanceof LoggerRepositoryEx) {
                            PluginRegistry pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry();
                            List list = pluginRegistry.getPlugins(Generator.class);

                            for (Iterator iter = list.iterator(); iter.hasNext();) {
                                Plugin plugin = (Plugin) iter.next();
                                pluginRegistry.stopPlugin(plugin.getName());
                            }
                        }
                    }
                }).start();
                setEnabled(false);
                startTutorial.putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    };

    stopTutorial.putValue(Action.SHORT_DESCRIPTION,
            "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched");
    startTutorial.putValue(Action.SHORT_DESCRIPTION,
            "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action");
    stopTutorial.setEnabled(false);

    final SmallToggleButton startButton = new SmallToggleButton(startTutorial);
    PropertyChangeListener pcl = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            stopTutorial.setEnabled(((Boolean) startTutorial.getValue("TutorialStarted")).equals(Boolean.TRUE));
            startButton.setSelected(stopTutorial.isEnabled());
        }
    };

    startTutorial.addPropertyChangeListener(pcl);
    stopTutorial.addPropertyChangeListener(pcl);

    pluginRegistry.addPluginListener(new PluginListener() {
        public void pluginStarted(PluginEvent e) {
        }

        public void pluginStopped(PluginEvent e) {
            List list = pluginRegistry.getPlugins(Generator.class);

            if (list.size() == 0) {
                startTutorial.putValue("TutorialStarted", Boolean.FALSE);
            }
        }
    });

    final SmallButton stopButton = new SmallButton(stopTutorial);

    final JToolBar tutorialToolbar = new JToolBar();
    tutorialToolbar.setFloatable(false);
    tutorialToolbar.add(startButton);
    tutorialToolbar.add(stopButton);
    container.add(tutorialToolbar, BorderLayout.NORTH);
    tutorialArea.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (e.getDescription().equals("StartTutorial")) {
                    startTutorial.actionPerformed(null);
                } else if (e.getDescription().equals("StopTutorial")) {
                    stopTutorial.actionPerformed(null);
                } else {
                    try {
                        tutorialArea.setPage(e.getURL());
                    } catch (IOException e1) {
                        MessageCenter.getInstance().getLogger()
                                .error("Failed to change the URL for the Tutorial", e1);
                    }
                }
            }
        }
    });

    /**
     * loads the saved tab settings and if there are hidden tabs,
     * hide those tabs out of currently loaded tabs..
     */

    if (!getTabbedPane().tabSetting.isWelcome()) {
        displayPanel(ChainsawTabbedPane.WELCOME_TAB, false);
    }
    if (!getTabbedPane().tabSetting.isZeroconf()) {
        displayPanel(ChainsawTabbedPane.ZEROCONF, false);
    }
    tbms.stateChange();

}

From source file:org.docx4all.ui.main.WordMLEditor.java

private JEditorPane createSourceView(WordMLTextPane editorView) {
    //Create the Source View
    JEditorPane sourceView = new JEditorPane();

    MutableAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attrs, FontManager.getInstance().getSourceViewFontFamilyName());
    StyleConstants.setFontSize(attrs, FontManager.getInstance().getSourceViewFontSize());

    // TODO - only do this if the font is available.
    Font font = new Font("Arial Unicode MS", Font.PLAIN, 12);

    System.out.println(font.getFamily());
    System.out.println(font.getFontName());
    System.out.println(font.getPSName());

    sourceView.setFont(font);/*from   ww w .ja va2 s.  c o  m*/
    //sourceView.setFont(FontManager.getInstance().getFontInAction(attrs));

    sourceView.setContentType("text/xml; charset=UTF-16");

    // Instantiate a XMLEditorKit with wrapping enabled.
    XMLEditorKit kit = new XMLEditorKit(true);
    // Set the wrapping style.
    kit.setWrapStyleWord(true);

    sourceView.setEditorKit(kit);

    WordMLDocument editorViewDoc = (WordMLDocument) editorView.getDocument();

    try {
        editorViewDoc.readLock();

        editorView.getWordMLEditorKit().saveCaretText();

        DocumentElement elem = (DocumentElement) editorViewDoc.getDefaultRootElement();
        WordprocessingMLPackage wmlPackage = ((DocumentML) elem.getElementML()).getWordprocessingMLPackage();
        String filePath = (String) editorView.getDocument().getProperty(WordMLDocument.FILE_PATH_PROPERTY);

        //Do not include the last paragraph which is an extra paragraph.
        elem = (DocumentElement) elem.getElement(elem.getElementCount() - 1);
        ElementML paraML = elem.getElementML();
        ElementML bodyML = paraML.getParent();
        paraML.delete();

        Document doc = DocUtil.read(sourceView, wmlPackage);
        doc.putProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath);
        doc.putProperty(WordMLDocument.WML_PACKAGE_PROPERTY, wmlPackage);
        doc.addDocumentListener(getToolbarStates());

        //Below are the properties used by bounce.jar library
        //See http://www.edankert.com/bounce/xmleditorkit.html
        doc.putProperty(PlainDocument.tabSizeAttribute, new Integer(4));
        doc.putProperty(XMLDocument.AUTO_INDENTATION_ATTRIBUTE, Boolean.TRUE);
        doc.putProperty(XMLDocument.TAG_COMPLETION_ATTRIBUTE, Boolean.TRUE);

        //Remember to put 'paraML' as last paragraph
        bodyML.addChild(paraML);

    } finally {
        editorViewDoc.readUnlock();
    }

    kit.setStyle(XMLStyleConstants.ATTRIBUTE_NAME, new Color(255, 0, 0), Font.PLAIN);

    sourceView.addFocusListener(getToolbarStates());
    //sourceView.setDocument(doc);
    sourceView.putClientProperty(Constants.LOCAL_VIEWS_SYNCHRONIZED_FLAG, Boolean.TRUE);

    return sourceView;
}

From source file:org.fit.cssbox.scriptbox.demo.tester.JavaScriptTesterUIPresenter.java

private JEditorPane addSourceCodeTab() {
    JScrollPane sourceCodeScrollPane = new JScrollPane();
    NEW_COUNTER++;/*  w ww . j av a2 s . c  o m*/
    sourceCodeTabbedPane.addTab("New " + NEW_COUNTER, null, sourceCodeScrollPane, null);
    sourceCodeTabbedPane.setSelectedIndex(sourceCodeTabbedPane.getTabCount() - 1);

    DefaultSyntaxKit.initKit();

    final JEditorPane codeEditor = new JEditorPane();
    sourceCodeScrollPane.setViewportView(codeEditor);

    codeEditor.setContentType("text/xhtml");

    return codeEditor;
}

From source file:org.isatools.isacreator.ontologyselectiontool.ViewTermDefinitionUI.java

private JEditorPane createOntologyInformationDisplay(OntologyBranch term) {

    JEditorPane ontologyInfo = new JEditorPane();
    ontologyInfo.setContentType("text/html");
    ontologyInfo.setEditable(false);//from  w w w  .j a va  2 s  . c om
    ontologyInfo.setBackground(UIHelper.BG_COLOR);

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 8.5px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    labelContent += "<b>Term name: </b>" + term.getBranchName() + "</p>";

    // special handling for ChEBI to get the structural image
    System.out.println("Showing CHEBI image for " + term.getBranchIdentifier());
    if (term.getBranchIdentifier().toLowerCase().contains("chebi")) {

        String chebiTermId = term.getBranchIdentifier()
                .substring(term.getBranchIdentifier().lastIndexOf("_") + 1);

        System.out.println("Showing CHEBI image for " + chebiTermId);

        String chebiImageURL = "http://www.ebi.ac.uk/chebi/displayImage.do?defaultImage=true&imageIndex=0&chebiId="
                + chebiTermId;
        labelContent += "<p><b>Chemical structure:</b>" + "<p/>" + "<img src=\"" + chebiImageURL
                + "\" alt=\"chemical structure for " + term.getBranchName()
                + "\" width=\"150\" height=\"150\"/>";

    }

    properties = sortMap(properties);

    if (properties != null && properties.size() > 0) {
        for (String propertyType : properties.keySet()) {
            if (propertyType != null) {

                labelContent += ("<p><b>" + propertyType + ": </b>");
                labelContent += (properties.get(propertyType) == null ? "no definition available"
                        : properties.get(propertyType) + "</font></p>");
            }
        }
    } else {
        labelContent += "<p>No definition found for this term! This can be due to 2 reasons: "
                + "1) Unfortunately, not all terms have their definitions supplied; and 2) the "
                + "ability to view the definitions for a term in this tool is not yet fully supported.</p>";
    }

    labelContent += "</body></html>";

    ontologyInfo.setText(labelContent);

    return ontologyInfo;
}

From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java

private JPanel prepareAssayInformation() {

    assayInformation.removeAll();/* w ww  .  j  ava2s.c om*/

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);
    currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30));

    Map<String, String> data = getAssayDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    assayInformation.add(currentlyShowingInfo);

    return assayInformation;
}

From source file:org.isatools.isacreator.visualization.InvestigationInfoPanel.java

private JPanel prepareInvestigationInformation() {

    investigationInformation.removeAll();

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);

    JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroller.setBackground(UIHelper.BG_COLOR);
    infoScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    infoScroller.setPreferredSize(new Dimension(width - 10, height - 50));
    infoScroller.setBorder(null);//from   ww w  . j  a  va2  s  . c  om

    IAppWidgetFactory.makeIAppScrollPane(infoScroller);

    Map<String, String> data = getInvestigationDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    investigationInformation.add(infoScroller);

    return investigationInformation;
}

From source file:org.isatools.isacreator.visualization.StudyInfoPanel.java

private JPanel prepareStudyInformation() {

    studyInformation.removeAll();//from   ww w.  j a  v  a2s  . c  o m

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);
    currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30));

    JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroller.setBackground(UIHelper.BG_COLOR);
    infoScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    infoScroller.setPreferredSize(new Dimension(width - 10, height - 50));
    infoScroller.setBorder(null);

    IAppWidgetFactory.makeIAppScrollPane(infoScroller);

    Map<String, String> data = getStudyDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    studyInformation.add(infoScroller);

    return studyInformation;
}

From source file:org.jannocessor.ui.RenderPreviewDialog.java

private JEditorPane createInput() {
    final JEditorPane editor = new JEditorPane();
    return editor;
}