Search in sources :

Example 1 with TextAnnotationImpl

use of org.cytoscape.ding.impl.cyannotator.annotations.TextAnnotationImpl in project cytoscape-impl by cytoscape.

the class TextAnnotationDialog method initComponents.

private void initComponents() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setModalityType(DEFAULT_MODALITY_TYPE);
    setResizable(false);
    setTitle(create ? "Create Text Annotation" : "Modify Text Annotation");
    // Create the preview panel
    preview = new TextAnnotationImpl(view, getOwner());
    preview.setUsedForPreviews(true);
    preview.getComponent().setSize(PREVIEW_WIDTH - 10, PREVIEW_HEIGHT - 10);
    PreviewPanel previewPanel = new PreviewPanel(preview);
    textAnnotationPanel = new TextAnnotationPanel(mAnnotation, previewPanel);
    getContentPane().add(textAnnotationPanel);
    getContentPane().add(previewPanel);
    applyButton = new JButton(new AbstractAction("OK") {

        @Override
        public void actionPerformed(ActionEvent e) {
            applyButtonActionPerformed(e);
        }
    });
    cancelButton = new JButton(new AbstractAction("Cancel") {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    final JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(applyButton, cancelButton);
    final JPanel contents = new JPanel();
    final GroupLayout layout = new GroupLayout(contents);
    contents.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createParallelGroup(LEADING, true).addComponent(textAnnotationPanel).addComponent(previewPanel, DEFAULT_SIZE, PREVIEW_WIDTH, Short.MAX_VALUE).addComponent(buttonPanel));
    layout.setVerticalGroup(layout.createSequentialGroup().addComponent(textAnnotationPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(previewPanel, DEFAULT_SIZE, PREVIEW_HEIGHT, Short.MAX_VALUE).addComponent(buttonPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), applyButton.getAction(), cancelButton.getAction());
    getRootPane().setDefaultButton(applyButton);
    getContentPane().add(contents);
    pack();
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout) TextAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.TextAnnotationImpl) AbstractAction(javax.swing.AbstractAction)

Example 2 with TextAnnotationImpl

use of org.cytoscape.ding.impl.cyannotator.annotations.TextAnnotationImpl in project cytoscape-impl by cytoscape.

the class TextAnnotationFactory method createAnnotation.

@Override
public TextAnnotation createAnnotation(Class<? extends TextAnnotation> type, CyNetworkView view, Map<String, String> argMap) {
    if (!(view instanceof DGraphView))
        return null;
    DGraphView dView = (DGraphView) view;
    if (type.equals(TextAnnotation.class)) {
        final TextAnnotationImpl a = new TextAnnotationImpl(dView, argMap, getActiveWindow());
        a.update();
        return (TextAnnotation) a;
    }
    return null;
}
Also used : TextAnnotation(org.cytoscape.view.presentation.annotations.TextAnnotation) TextAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.TextAnnotationImpl) DGraphView(org.cytoscape.ding.impl.DGraphView)

Aggregations

TextAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.TextAnnotationImpl)2 ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 GroupLayout (javax.swing.GroupLayout)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1 DGraphView (org.cytoscape.ding.impl.DGraphView)1 TextAnnotation (org.cytoscape.view.presentation.annotations.TextAnnotation)1