Search in sources :

Example 21 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class Launcher method initialize.

/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
    frame.setBackground(Color.BLACK);
    frame.getContentPane().setBackground(Color.BLACK);
    frame.setResizable(false);
    {
        frame.setBounds(100, 100, 551, 558);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    }
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    northPanel = new JPanel();
    northPanel.setBackground(Color.BLACK);
    northPanel.setPreferredSize(new Dimension(0, 78));
    frame.getContentPane().add(northPanel, BorderLayout.NORTH);
    centerPanel = new JPanel();
    centerPanel.setBackground(Color.BLACK);
    frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
    centerPanel.setLayout(new BorderLayout(0, 0));
    mainTabbedPane = new JTabbedPane(JTabbedPane.TOP);
    mainTabbedPane.setBackground(Color.BLACK);
    centerPanel.add(mainTabbedPane, BorderLayout.CENTER);
    JPanel startPanel_1 = new JPanel();
    startPanel_1.setForeground(SystemColor.menu);
    startPanel_1.setBackground(Color.BLACK);
    mainTabbedPane.addTab("Start", null, startPanel_1, null);
    startPanel_1.setLayout(new BorderLayout(0, 0));
    JPanel panel_2 = new JPanel();
    panel_2.setBackground(Color.BLACK);
    panel_2.setPreferredSize(new Dimension(10, 60));
    startPanel_1.add(panel_2, BorderLayout.SOUTH);
    panel_2.setLayout(null);
    launchButton = new JButton("Start");
    panel_2.add(launchButton);
    launchButton.setBounds(220, 5, 128, 48);
    launchButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            launchAction();
        }
    });
    launchButton.setPreferredSize(new Dimension(128, 48));
    launchButton.setForeground(SystemColor.menu);
    launchButton.setBorderPainted(false);
    launchButton.setBackground(Color.BLACK);
    debugCmb = new JCheckBox("Debug");
    debugCmb.setBounds(59, 20, 144, 18);
    debugCmb.setToolTipText("Trace the launching process and record messages");
    debugCmb.setForeground(SystemColor.menu);
    debugCmb.setBackground(Color.BLACK);
    panel_2.add(debugCmb);
    lowPriorityCBx = new JCheckBox("Low priority");
    lowPriorityCBx.setToolTipText("Launch the application with low process-priority (recommended, but currently only works with Windows)");
    lowPriorityCBx.setForeground(SystemColor.menu);
    lowPriorityCBx.setBackground(Color.BLACK);
    lowPriorityCBx.setBounds(404, 35, 135, 18);
    panel_2.add(lowPriorityCBx);
    JLabel label = new JLabel();
    label.setText("UI scale");
    label.setPreferredSize(new Dimension(94, 22));
    label.setForeground(Color.LIGHT_GRAY);
    label.setFont(new Font("Dialog", Font.BOLD, 10));
    label.setBounds(389, 5, 49, 22);
    panel_2.add(label);
    uiScaleEdit = new JTextField();
    uiScaleEdit.setToolTipText("Scales up the UI, works best with Java9");
    uiScaleEdit.setText("1");
    uiScaleEdit.setPreferredSize(new Dimension(56, 22));
    uiScaleEdit.setFont(new Font("Dialog", Font.PLAIN, 10));
    uiScaleEdit.setBounds(438, 5, 56, 22);
    panel_2.add(uiScaleEdit);
    mainPanel = new JPanel();
    mainPanel.setBackground(Color.BLACK);
    startPanel_1.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(null);
    maxMemField = new JTextField();
    maxMemField.setBounds(141, 38, 92, 22);
    mainPanel.add(maxMemField);
    maxMemField.setText("1024");
    maxMemField.setPreferredSize(new Dimension(56, 22));
    maxMemField.setFont(new Font("Dialog", Font.PLAIN, 10));
    JLabel lblMb = new JLabel();
    lblMb.setBounds(234, 38, 30, 22);
    mainPanel.add(lblMb);
    lblMb.setForeground(Color.LIGHT_GRAY);
    lblMb.setText("MB");
    lblMb.setPreferredSize(new Dimension(94, 22));
    lblMb.setFont(new Font("Dialog", Font.BOLD, 10));
    JLabel lblMemoryToUse = new JLabel();
    lblMemoryToUse.setBounds(19, 38, 107, 22);
    mainPanel.add(lblMemoryToUse);
    lblMemoryToUse.setForeground(Color.LIGHT_GRAY);
    lblMemoryToUse.setText("Memory to use");
    lblMemoryToUse.setPreferredSize(new Dimension(94, 22));
    lblMemoryToUse.setFont(new Font("Dialog", Font.BOLD, 10));
    btnAddJavaRuntime = new JButton("Add Java runtime...");
    btnAddJavaRuntime.setToolTipText("Manually add the path of a Java runtime which is installed on this system andwas not detected by the launcher");
    btnAddJavaRuntime.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            manualAddRuntime();
        }
    });
    btnAddJavaRuntime.setBounds(276, 34, 172, 28);
    mainPanel.add(btnAddJavaRuntime);
    btnAddJavaRuntime.setPreferredSize(new Dimension(128, 28));
    btnAddJavaRuntime.setForeground(SystemColor.menu);
    btnAddJavaRuntime.setBorderPainted(false);
    btnAddJavaRuntime.setBackground(Color.BLACK);
    jdkCmb = new JComboBox();
    jdkCmb.setBounds(142, 6, 384, 22);
    mainPanel.add(jdkCmb);
    jdkCmb.setForeground(SystemColor.menu);
    jdkCmb.setBackground(Color.BLACK);
    jdkCmb.setPreferredSize(new Dimension(125, 22));
    jdkCmb.setMaximumRowCount(32);
    jdkCmb.setFont(new Font("Dialog", Font.BOLD, 10));
    JLabel lblJavaRuntimeTo = new JLabel();
    lblJavaRuntimeTo.setBounds(19, 6, 107, 22);
    mainPanel.add(lblJavaRuntimeTo);
    lblJavaRuntimeTo.setForeground(Color.LIGHT_GRAY);
    lblJavaRuntimeTo.setText("Java runtime to use");
    lblJavaRuntimeTo.setPreferredSize(new Dimension(94, 22));
    lblJavaRuntimeTo.setFont(new Font("Dialog", Font.BOLD, 10));
    JPanel logPanel = new JPanel();
    logPanel.setBackground(Color.BLACK);
    logPanel.setForeground(SystemColor.menu);
    mainTabbedPane.addTab("Message log", null, logPanel, null);
    logPanel.setLayout(new BorderLayout(0, 0));
    JPanel panel = new JPanel();
    panel.setBackground(Color.BLACK);
    panel.setPreferredSize(new Dimension(10, 38));
    logPanel.add(panel, BorderLayout.SOUTH);
    JButton toClipboardBtn = new JButton("To Clipboard");
    toClipboardBtn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection data = new StringSelection(getLogTextArea().getText());
            clipboard.setContents(data, data);
        }
    });
    toClipboardBtn.setPreferredSize(new Dimension(128, 28));
    toClipboardBtn.setForeground(SystemColor.menu);
    toClipboardBtn.setBorderPainted(false);
    toClipboardBtn.setBackground(Color.BLACK);
    panel.add(toClipboardBtn);
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBackground(Color.DARK_GRAY);
    logPanel.add(scrollPane, BorderLayout.CENTER);
    logTextArea = new JTextArea();
    logTextArea.setForeground(Color.LIGHT_GRAY);
    logTextArea.setEditable(false);
    logTextArea.setBackground(Color.BLACK);
    scrollPane.setViewportView(logTextArea);
    imgDisplayPanel = new JPanel();
    imgDisplayPanel.setBackground(Color.BLACK);
    imgDisplayPanel.setBounds(20, 86, 500, 270);
    mainPanel.add(imgDisplayPanel);
    JButton btnReset = new JButton("Reset");
    btnReset.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            resetToDefaultsBtn_clicked();
        }
    });
    btnReset.setToolTipText("Rest all laucher settings to defaults (may be useful after system upgrade)");
    btnReset.setPreferredSize(new Dimension(128, 28));
    btnReset.setForeground(SystemColor.menu);
    btnReset.setBorderPainted(false);
    btnReset.setBackground(Color.BLACK);
    btnReset.setBounds(460, 34, 66, 28);
    mainPanel.add(btnReset);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) Font(java.awt.Font) StringSelection(java.awt.datatransfer.StringSelection) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JFrame(javax.swing.JFrame) Clipboard(java.awt.datatransfer.Clipboard)

Example 22 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class EnvelopeDlgController method exportRawDataToClipboard.

public void exportRawDataToClipboard() {
    String motionData = getRawMotionData("");
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection data = new StringSelection(motionData);
    clipboard.setContents(data, data);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 23 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class EnvelopeDlgController method importRawDataFromClipboard.

public void importRawDataFromClipboard() {
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String data = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                importRawMotionData(data);
                enableControls();
            } else {
                throw new Exception("No text-data in the clipboard");
            }
        } else {
            throw new RuntimeException("No data in the clipboard");
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard)

Example 24 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class FlamesGPURenderController method fromClipboardButton_clicked.

public void fromClipboardButton_clicked() {
    Flame newFlame = null;
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                List<Flame> flames = new FlameReader(prefs).readFlamesfromXML(xml);
                if (flames.size() > 0) {
                    newFlame = flames.get(0);
                }
            }
        }
        if (newFlame == null) {
            throw new Exception("There is currently no valid flame in the clipboard");
        } else {
            currFlame = newFlame;
            enableControls();
            setupProfiles(currFlame);
            renderFlame();
            enableControls();
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame)

Example 25 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class TinaController method saveFlameToClipboard.

public void saveFlameToClipboard() {
    try {
        if (getCurrFlame() != null) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            String xml = new FlameWriter().getFlameXML(generateExportFlame(getCurrFlame()));
            StringSelection data = new StringSelection(xml);
            clipboard.setContents(data, data);
            messageHelper.showStatusMessage(getCurrFlame(), "flame saved to clipboard");
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)172 StringSelection (java.awt.datatransfer.StringSelection)110 Transferable (java.awt.datatransfer.Transferable)43 IOException (java.io.IOException)27 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)15 ActionEvent (java.awt.event.ActionEvent)12 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)9 JButton (javax.swing.JButton)8 JMenuItem (javax.swing.JMenuItem)8 JScrollPane (javax.swing.JScrollPane)8 JPanel (javax.swing.JPanel)7 JTextArea (javax.swing.JTextArea)7 Foundation (org.concord.energy3d.model.Foundation)7 HousePart (org.concord.energy3d.model.HousePart)7 FlameReader (org.jwildfire.create.tina.io.FlameReader)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 Point (java.awt.Point)6