[JAVA] astah * plugin development snippet

Get the currently open diagram
IDiagramViewManager diagramViewManager = api.getViewManager().getDiagramViewManager();
IDiagram currentDiagram = diagramViewManager.getCurrentDiagram();
Get selected diagram element
IDiagramViewManager diagramViewManager = api.getViewManager().getDiagramViewManager();
List<IPresentation> iPresentationList = Arrays.asList(diagramViewManager.getSelectedPresentations());
Change text color

Example: imp is INodePresentation. I wonder if I can go if it is derived from IPresentation.

inp.setProperty(Key.FONT_COLOR, "#FF0000");
Simple text dialog
package xyz.astah.example;
 
import java.awt.Frame;
import java.awt.Insets;
 
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
public class TextDialog extends JDialog {
    public TextDialog(String text, Frame frame, int width, int height, boolean modal) {
        super(frame, "Text Dialog", modal);
 
        JTextArea jTextArea = new JTextArea(text);
        jTextArea.setMargin(new Insets(8, 8, 8, 8));
 
        JScrollPane jScrollPane = new JScrollPane(jTextArea);
 
        this.getContentPane().add(jScrollPane);
        this.setBounds(frame.getX() + 100, frame.getY() + 100, width, height);
        this.setVisible(true);
    }
}

Example of use

TextDialog textDialog = new TextDialog(outputText.toString(), api.getViewManager().getMainFrame(), 300, 300, false);

Recommended Posts

astah * plugin development snippet
Plugin development with ImageJ
THETA plugin development (about theta-plugin-sdk)
[Eclipse plug-in development] Javadoc acquisition
Convenient plugin for Eclipse JAVA development: Decompiler