Search in sources :

Example 1 with ShapeAnnotation

use of org.cytoscape.view.presentation.annotations.ShapeAnnotation in project cytoscape-impl by cytoscape.

the class ShapeAnnotationFactory method createAnnotation.

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

Example 2 with ShapeAnnotation

use of org.cytoscape.view.presentation.annotations.ShapeAnnotation in project cytoscape-impl by cytoscape.

the class BoundedTextAnnotationDialog method initComponents.

private void initComponents() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setModalityType(DEFAULT_MODALITY_TYPE);
    setResizable(false);
    setTitle(create ? "Create Bounded Text Annotation" : "Modify Bounded Text Annotation");
    // Create the preview panel
    preview = new BoundedTextAnnotationImpl(view, getOwner());
    preview.setUsedForPreviews(true);
    preview.setText(mAnnotation.getText());
    preview.setFont(mAnnotation.getFont());
    preview.fitShapeToText();
    PreviewPanel previewPanel = new PreviewPanel(preview);
    shapeAnnotationPanel = new ShapeAnnotationPanel((ShapeAnnotation) mAnnotation, previewPanel);
    textAnnotationPanel = new TextAnnotationPanel((TextAnnotation) mAnnotation, 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(shapeAnnotationPanel).addComponent(textAnnotationPanel).addComponent(previewPanel, DEFAULT_SIZE, PREVIEW_WIDTH, Short.MAX_VALUE).addComponent(buttonPanel));
    layout.setVerticalGroup(layout.createSequentialGroup().addComponent(shapeAnnotationPanel, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).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) BoundedTextAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.BoundedTextAnnotationImpl) ActionEvent(java.awt.event.ActionEvent) ShapeAnnotation(org.cytoscape.view.presentation.annotations.ShapeAnnotation) JButton(javax.swing.JButton) GroupLayout(javax.swing.GroupLayout) TextAnnotation(org.cytoscape.view.presentation.annotations.TextAnnotation) AbstractAction(javax.swing.AbstractAction)

Aggregations

ShapeAnnotation (org.cytoscape.view.presentation.annotations.ShapeAnnotation)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 BoundedTextAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.BoundedTextAnnotationImpl)1 ShapeAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ShapeAnnotationImpl)1 TextAnnotation (org.cytoscape.view.presentation.annotations.TextAnnotation)1