aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/jogamp/opencl/demos/info/CLInfo.java21
-rw-r--r--src/com/jogamp/opencl/util/64_35.pngbin0 -> 8705 bytes
-rw-r--r--src/com/jogamp/opencl/util/ExceptionReporter.form129
-rw-r--r--src/com/jogamp/opencl/util/ExceptionReporter.java165
4 files changed, 314 insertions, 1 deletions
diff --git a/src/com/jogamp/opencl/demos/info/CLInfo.java b/src/com/jogamp/opencl/demos/info/CLInfo.java
index af7e30c..0975f7b 100644
--- a/src/com/jogamp/opencl/demos/info/CLInfo.java
+++ b/src/com/jogamp/opencl/demos/info/CLInfo.java
@@ -4,24 +4,43 @@
package com.jogamp.opencl.demos.info;
+import com.jogamp.common.JogampRuntimeException;
import com.jogamp.opencl.CLDevice;
import com.jogamp.opencl.CLPlatform;
+import com.jogamp.opencl.util.ExceptionReporter;
import java.awt.Container;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
+import javax.swing.UIManager;
/**
- *
+ * Displays OpenCL information in a table.
* @author Michael Bien
*/
public class CLInfo {
public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception ex) {
+ Logger.getLogger(CLInfo.class.getName()).log(Level.INFO, null, ex);
+ }
+
+ try{
+ CLPlatform.initialize();
+ }catch(JogampRuntimeException ex) {
+ Logger.getLogger(CLInfo.class.getName()).log(Level.SEVERE, null, ex);
+ ExceptionReporter.appear("I tried hard but I really can't initialize JOCL. Is OpenCL properly set up?", ex);
+ return;
+ }
+
JFrame frame = new JFrame("OpenCL Info");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Container contentPane = frame.getContentPane();
diff --git a/src/com/jogamp/opencl/util/64_35.png b/src/com/jogamp/opencl/util/64_35.png
new file mode 100644
index 0000000..507fdb5
--- /dev/null
+++ b/src/com/jogamp/opencl/util/64_35.png
Binary files differ
diff --git a/src/com/jogamp/opencl/util/ExceptionReporter.form b/src/com/jogamp/opencl/util/ExceptionReporter.form
new file mode 100644
index 0000000..d492479
--- /dev/null
+++ b/src/com/jogamp/opencl/util/ExceptionReporter.form
@@ -0,0 +1,129 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="icon" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jScrollPane2" pref="396" max="32767" attributes="0"/>
+ <Component id="jScrollPane1" alignment="0" pref="396" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <Component id="okButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="reportButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="icon" min="-2" max="-2" attributes="1"/>
+ <Group type="102" attributes="0">
+ <Component id="jScrollPane2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
+ <Component id="jScrollPane1" pref="146" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="reportButton" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="icon">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+ <Image iconType="3" name="/com/jogamp/opencl/util/64_35.png"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="reportButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="not at all. I file a bug!"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="reportButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="okButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="understood"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JEditorPane" name="messagePane">
+ <Properties>
+ <Property name="contentType" type="java.lang.String" value="text/html"/>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextPane" name="description">
+ <Properties>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="focusable" type="boolean" value="false"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/src/com/jogamp/opencl/util/ExceptionReporter.java b/src/com/jogamp/opencl/util/ExceptionReporter.java
new file mode 100644
index 0000000..17b92cc
--- /dev/null
+++ b/src/com/jogamp/opencl/util/ExceptionReporter.java
@@ -0,0 +1,165 @@
+/*
+ * Created on Sep 10, 2010, 6:12:26 PM
+ */
+
+package com.jogamp.opencl.util;
+
+import com.jogamp.common.JogampRuntimeException;
+import java.awt.Component;
+import java.awt.Desktop;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URI;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JEditorPane;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingConstants;
+import javax.swing.WindowConstants;
+
+/*
+ * Icon used in the dialog is from http://lazycrazy.deviantart.com/ released under the CC attibution license.
+ */
+
+/**
+ *
+ * @author Michael Bien
+ */
+public class ExceptionReporter extends JDialog {
+
+ public ExceptionReporter(Frame parent, boolean modal) {
+ super(parent, "Something went wrong", modal);
+ initComponents();
+ }
+
+ public static void appear(String string, JogampRuntimeException ex) {
+ ExceptionReporter reporter = new ExceptionReporter(null, true);
+ reporter.setLocationRelativeTo(null);
+ reporter.description.setText(string);
+
+ StringBuilder sb = new StringBuilder();
+ final Writer result = new StringWriter();
+ ex.printStackTrace(new PrintWriter(result));
+
+ sb.append("<pre>").append(result.toString()).append("</pre>");
+ reporter.messagePane.setText(sb.toString());
+ reporter.setVisible(true);
+
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+ JLabel icon = new JLabel();
+ JButton reportButton = new JButton();
+ JButton okButton = new JButton();
+ JScrollPane jScrollPane1 = new JScrollPane();
+ messagePane = new JEditorPane();
+ JScrollPane jScrollPane2 = new JScrollPane();
+ description = new JTextPane();
+
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ icon.setIcon(new ImageIcon(getClass().getResource("/com/jogamp/opencl/util/64_35.png"))); // NOI18N
+
+ reportButton.setText("not at all. I file a bug!");
+ reportButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ reportButtonActionPerformed(evt);
+ }
+ });
+
+ okButton.setText("understood");
+ okButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ okButtonActionPerformed(evt);
+ }
+ });
+
+ messagePane.setContentType("text/html");
+ messagePane.setEditable(false);
+ jScrollPane1.setViewportView(messagePane);
+
+ description.setEditable(false);
+ description.setFocusable(false);
+ jScrollPane2.setViewportView(description);
+
+ GroupLayout layout = new GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(icon)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)))
+ .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
+ .addComponent(okButton)
+ .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addComponent(reportButton)))
+ .addContainerGap())
+ );
+
+ layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {okButton, reportButton});
+
+ layout.setVerticalGroup(
+ layout.createParallelGroup(Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(icon)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addGap(4, 4, 4)
+ .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(Alignment.BASELINE)
+ .addComponent(reportButton)
+ .addComponent(okButton))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void reportButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_reportButtonActionPerformed
+ try {
+ Desktop.getDesktop().browse(URI.create("http://www.jogamp.org/bugzilla/"));
+ } catch (IOException ex) {
+ Logger.getLogger(ExceptionReporter.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }//GEN-LAST:event_reportButtonActionPerformed
+
+ private void okButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+ dispose();
+ }//GEN-LAST:event_okButtonActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private JTextPane description;
+ private JEditorPane messagePane;
+ // End of variables declaration//GEN-END:variables
+
+}